Link: Online jqueryhttp://www.bootcdn.cnone, each (traversal)
1 $ ("ul Li"). each (function(index,value) {2 alert (index+ ":" +$ ("value"). html ()); 3 }) 4 5 6 7 $.each ("ul Li"), function(index,value) {8 alert (index + ":" +$ (value). HTML ()); 9 })
Second, Ajax
1Oneload ()2 31. Get information (content only, no formatting restrictions)4$ ("#btn"). Click (function(){5$ ("#box"). Load ("Abc.txt");//URL must be written6 })7 82. Get the content and style of other pages9$ ("#btn"). Click (function(){Ten$ ("#box"). Load ("info.html",function(){ One$ (". Zzl"). Click (function(){ AAlert ($ ( This). HTML ()) - }) - }) the }) - -Second, $ajax----Get PHP - +$ ("#btn"). Click (function(){ - $.ajax ({ +Type: "Get", AURL: "demo.php", atAsynctrue, -Data: "User= dog son &pwd=123", -Successfunction(data) { - alert (data); - }, -DataType: "HTML" in }); -})
Third, GET
11. Get page2 3$ ("#btn"). Click (function(){4$.get ("memo.html",function(Responese) {5$ ("#box"). HTML (Responese);6 })7})//get content from a page8 92. Get PHPTen One$ ("#btn"). Click (function(){ A$.get ("Demo.php?name= Zhang Zhilin &pwd=zzl123",function(Responese) { - alert (Responese); -$ ("#box"). HTML (Responese); the }) -})//All PHP content - -3. Map Format + -$ ("#btn"). Click (function(){ +$.get ("demo.php",{ AName: "Zhang Zhilin", atPWD: "Zzl123" -},function(response) { - alert (response); -$ ("#box"). HTML (response) - }) -})//All PHP content in -4. String to$ ("#btn"). Click (function(){ +$.get ("demo.php", "Name= Zhang Zhilin &pwd=zzl123",function(response) { -alert (response);//All PHP content the$ ("#box"). HTML (response); * }) $ })Panax Notoginseng -5. Accessing the XML file the$ ("#btn"). Click (function(){ +$.get ("Demo.xml",function(Responese) { Aalert (Responese);//[Object XMLDocument] the varData =$ (Responese). Find ("root"). Find ("User"). html (); +Alerttypeofdata);//string - vararr = Data.split (":"); $Alert (arr[0]+ "----" +arr[1])//get the middle content of subscript 0-1 $ }) -})
Four, get JSON
1 $ ("#btn"). Click (function() {2 $.get ("Demo.json",function(response) { 3 //alert (response) //json all content 4 $ ("#box"). Append ( $ ("//JSON content section 5 })6 })
Status code
DOM(i), create element node: $ (HTML): Create Node "example $ (" <div title =' box ' >dom</div> ') '(ii), create text
var $div = $ ("<Div> dom</div>")
$ ("Body"). Append ($div)
(c), setting properties
var $div = $ ("<div title= ' div box ' > I am dom</div>") $ (
(iv), insert--a--internal Insert (subset) 1). Append (): Adds content (end) 2 to the inside of the element.appendTo () : Adding content to an element 3). Prepend (): Add content to the inside of the Element (predecessor) 4). Prependto (): Add content to the element--b--external insertion (sibling) 1). After (): Insert content after element 2).InsertAfter (): Inserting content behind an element 3).before (): inserting content before an element4). InsertBefore (): Inserts content in front of the element(v), deleteRemove (): Delete the matching element (delete completely)Empty (): the contents of the clearance node (vi), cloning-----> Create a copy of the specified nodeClone ()true: Represents replication properties, styles, and events (vii), replacement 1. ReplaceWith (): replaces the specified element with the matching element 2. ReplaceAll (): Replace the specified element with a matching element
Jquer __ajax DOM