Home >Web Front-end >JS Tutorial >Jquery study notes (1)_jquery

Jquery study notes (1)_jquery

WBOY
WBOYOriginal
2016-05-16 18:44:55743browse

Basic knowledge:
If you want to separate structure and behavior, of course you cannot use things like . js is written between , then Speaking of window.onload - this is not a good thing, so there is Jquery's creative

copy code The code is as follows :

$(document).ready(funciton(){

});

Of course it will be more streamlined:
Copy code The code is as follows:

$(function(){

});

So my first Jquery script looked like this.
$(function(){alert("I'm ready")});
Jquery object methods and DOM object methods cannot be mixed. For example, $("#id").innerHTML or document.getElementById("id").html() are both wrong.
Conversion between Jquery objects and DOM objects. The objects returned by the Jquery selector are actually returned as object arrays, so array subscripts can be used for conversion. You can also use the get(index) method in Jquery
Copy the code The code is as follows:

$ (function(){
var $p=$("p");
var p=$p[0];//var p=$p.get(0);
alert(p .innerHTML);
});

You can also convert DOM objects into Jquery objects
Copy code The code is as follows:

var p=document.getElementById("p");
var $p=$(p);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn