<script type= "Text/javascript" src= "Jquery-1.8.2.min.js" ></script>
<script type= "Text/javascript" >
$ (function () {
var arr={"Zhang San": 80, "John Doe": 78, "Zhao Wu": 85};
var str= "<li class= ' title ' > Name: Score </li>";
$.each (Arr,function (index,value) {//traversal array
str+= "<li>" +index+ ":" +value+ "</li>";
})
$.each ($.ajaxsettings,function (property,value) {//Traversal object
str+= "<li>" +property+ ":" +value+ "</li>";
})
$ ("ul"). Append (str);
Data filtering
var strtmp= "Pre-screening data:";
var arrnum=[4,6,2,5,10,13,1,30];
var arrget=$.grep (arrnum,function (ele,index) {//Tool function, $.grep () function filters any element in the array
return ele<10 && index<4
})
Change the elements in an array
var arrmap=$.map (arrnum,function (ele,index) {//Tool function, $.map () function changes the elements in the array
if (ele<10 && index< 4)
return ele+1;
})
Strtmp+=arrnum.join ();
strtmp+= "<br></br> filtered data:";
Strtmp+=arrget.join ();
Strtmp+=arrmap.join ();
$ ("#divTip"). Append (strtmp);
Search for the position of the specified element in the array
var arrinarray=$.inarray (10,arrnum); The $.inarray () function searches the position of the specified element in the array
strinarray= "Search results:";
Strinarray+=arrinarray;
$ ("#divTip"). Append (Strinarray);
})
</script>
<body>
<ul></ul>
<div id= "Divtip" ></div>
</body>