ol
or ul
Tags) utilizing jquery. Let’s use reverse()
operate out there in jquery library.
Let’s contemplate we have now an inventory of some ordered parts, say an inventory of some Indians cities. Now to reverse the listing first we have to get that every one factor in an array. That we are able to do through the use of jquery’s get()
methodology. After getting the whole out there factor from an inventory, name reverse to vary the present order of the array.
As soon as the array is reversed, name jquery’s every()
methodology to iterate over reversed array. Following code snippet exhibit how one can reverse an ordered metropolis listing and re-arrange it to point out to the person utilizing every()
methodology.
1
2
3
4
5
6
7
8
9
|
$(doc).prepared(operate(){
$(“#rev”).click on(operate(){
var listing = $(“ol li”).get().reverse();
$(“ol”).empty();
$.every(listing, operate(i){
$(“ol”).append(“
“ );});//every
});//operate
});//prepared
|
Download SourceView Online Demo
Supply techzoo.org