JQuery Magic (1) $("tagName") The getElementsByTagName() method in DOM behaves in JQuery as simply as $("tagName")!
Anonymous function to solve the window.onload event
Start with all "div" tags on the page and define a unified appearance
Define the appearance of the "body" tag
Dynamicly add a "span" tag and place it in "body"
JQuery Test< /title>
First div
Second div
Third div< ;/div>
JQuery magic (2) selector tag tag (can be: p, div, button...) The tag itself has attributes such as ID and Class
$("tag") //Get the collection of certain tags in the page and document.getElementsByTagName("tag")
$("#id") //Get the elements in the page based on id and document. .getElementById("id")
$("tag#id") //Get the tag element set based on id
$(".class") //Get the element set based on class document.getElementsByClassName( "class")
$("tag.class") //Get the set of elements with tag tag according to class
$("tag1 tag2") //Get the tag2 type elements in tag1 with the same as
$ ("tag1 > tag2")
$("tag1:has(tag2)") //Get a collection of tag1 type elements containing tag2
The above selector fully reflects the existence of JQuery The value is that the syntax is concise and the semantics are easy to understand.
Statement of this Website
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