Jquery Document: Api.jquery.com
Dom Objects and jquery objects
if (obj.nodetype) //Detect DOM Object return 1if (obj.jquery) //Detect jquery Object Ruturn jquery version 1.12.4 conversion var jqueryobj=$ (domobj); $ () package var domobj=jqueryobj.get ([index]); Get method
Create an HTML element:
var div=$ ("<div>hello</div>"); Create a $ () package for the Html.console.log (DIV); Output Dom Divconsole.log ($ ("div")); The jquery selector is not available and the page is not visible. Div.appendto ("body"); Append to body last face. Console.log ($ ("div"));//The page appears, the jquery selector is selected.
Create/Add Property
var link1=$ (' <a> ', { text: ' Baidu ', href: ' http://www.baidu.com ', target: ' _blank ', title: ' goto Baidu '}); Link1.appendto (' body ');//The first method is suitable for empty elements. var link2=$ (' <a>baidu</a> '). attr ({ href: ' http://www.baidu.com ', target: ' _blank ', title: ' goto Baidu '); Link2.appendto (' body ');
The second use of attr ();
jquery operations
$ (). length; check element [index] //Extract element, return Domget ([]) //Extract element, return Domget () //No index, return array object. Get ( -1) //take from the last element. -2,-3 backwards in turn. Undefined occurs across the border. eq (index) Returns a JQuery object.
First () //One
Last () //FINAL
The performance of the method is greater than the filter;
ToArray () returns the collection as if it were not a parameter.
MU Lesson jQuery 2018/6/21