1. $(document) converts the document object into jquery
$(document).ready(function(){
alert("hello world");
});
2. Obtain all hyperlink objects and add onclick events; In fact, the underlying jquery object obtains an array of each tag, so we do not need to loop
$(document).ready(function(){
$("a").click(function(){
alert("hello world");
});
});
3. Conversion between jquery objects and dom objects
$(document).ready(function(){
var javascriptElement = document.getElementById("clickme");
//Convert dom object to jquery object
var jqueryElement = $(javascriptElement);
//alert("javascript:" javascriptElement.innerHTML);//innerHTML gets the content of the tag
//alert("jquery:" jqueryElement.html());
//Convert jquery to dom object method 1
var jElement = $("#clickme");
var javascriptEle = jElement[0];
alert("jquery1: " javascriptEle.innerHTML);
//Method 2
var javascriptEle2 = jElement.get(0);
alert("jquery2: " javascriptEle2.innerHTML);
});
4. jquery solves the problem of whether the id value exists
5. It is stipulated in JavaScript that when you want to operate a CSS attribute, you must remove the ‘-’ in the attribute and capitalize the last letter; for example: background-color should be changed to backgroundColor
6. Selectors are also used in jquery to manipulate various elements . It inherits the design concept of CSS, but carries it forward;
7. Several writing forms of jquery
1> Method 1
$("document").ready(function(){
...
});
2> Method 2
$().ready(function(){
...
});
3> Method 3
$(function(){
...
});
The above methods are the same
I hope this article will be helpful to everyone learning jquery programming.
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