Reputation: 401
now i am using jquery to get ids of ul and li from top to bottom .but i cant able to get it from bottom to top . iam using the following code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function next_click()
{
alert("next");
var toHighlight = jQuery('.current').next().length > 0 ? jQuery('.current').next() : jQuery('#men_shirt li').first();
jQuery('.current').removeClass('current');
toHighlight.addClass('current');
$('#men_shirt ul li').each(function(i)
{
var iid=$(this).attr('id');
alert("sdfsdf"+iid);
});
var a=jQuery('li').hasClass('current');
alert(a);
if(a=='style')
{
set_menuselected('Style');
}
}
</script>
Please advise on this
Upvotes: 0
Views: 299
Reputation: 3600
Use .get().reverse()
See Help
$.each('#men_shirt ul li').get().reverse(),function(i)//use get.reverse method()
{
var iid=$(this).attr('id');
alert("sdfsdf"+iid);
});
Upvotes: 1
Reputation: 18670
You can extend jQuery with the reverse method:
jQuery.fn.reverse = [].reverse;
And then:
$('#men_shirt ul li').reverse().each(function() {
...
});
Upvotes: 0