Introduction of two functions (arrays) First
1.$.map (Array,function (Element,index));
For each element in the array, call the function (Element,index) as shown above, and eventually return a new array. The original array does not change.
Case:
<script type= "Text/javascript" >
Double the value of the element with an index value greater than 3.
var arr=[2,3,4,5,6,7,8];
var Nwarr = $.map (arr,function (ele,index) {
Return index>3?ele*2:ele;
});
alert (Nwarr);
</script>
2.each(ARRAY,FN)
Iterate through the array, return false to exit the loop.
It is used primarily to iterate through an array, not to modify an array, or to have no problem with an ordinary array or a "key-value pair" array.
You can use this directly in the each function to represent the value of the current element.
Case:
var dic={"name": ' Xiao Ming ', ' age ': at all, ' gender ': ' Male '};
$.each (Dic,function (key,value) {
Alert (key+ '---' +value);
});
jquery objects, DOM objects
1. conversion
Dom objects if you want to invoke jquery, the method must first be converted to a jquery object.
2.Dom Objects
Objects in the document tree are DOM objects.
3.jquery objects
When you wrap the DOM object, you get the jquery object.
4.dom→jquery
How do I convert a DOM object to a jquery object?
$ (spobj). Get (0). InnerHTML
$ (spobj) [0].innerhtml
5. Get the elements on the page directly from the jquery method
$ (' #id '), $ (' span '), $ ('. CLS ') 、......
The jquery object is called:. Text (), Val (), HTML (), CSS (' Color ', ' red ') 、......。 Most of jquery is a method with few attributes, because properties are difficult to chain-program. Getting the value, setting the value is the same method that is used, the parameter represents the set value, and no parameter represents the value.
6. which do not need to go to jquery objects
The array itself is not a DOM object. There is no conversion between the jquery objects. Using jquery statements you can use arrays directly, like $.each () or $.map ();
Add: The return value obtained by document.getElementsByTagName () or Document.getelementsbyname () is an array-like value, but not an array, with no array-specific methods.
parseint () \array These are not required to be converted.
Several basic operations of jquery