<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title> <Scripttype= ' Text/javascript 'src= ' Http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js '></Script> <Script> $(function(){ //-------------------------------jquery html () [parsing HTML tags] //1. No parameter HTML (): Gets the HTML content of the [first] matching element, which cannot be used in an XML document. But it can be used in an XHTML document, which returns a string varphtml= $('P'). html (); Console.log (phtml); //2. Parameter HTML (val): Sets the HTML content of the [each] matching element, which cannot be used in an XML document, but can be used in an XHTML document, the included HTML tags will be parsed, and a jquery object is returned $('P'). HTML ('<b> was replaced with the demo text of the </b> P element'); //3. The parameter is the HTML of the callback function (funtion (index, HTML) {...}): The first parameter represents the index position of the current element (index starts at 0), and the second parameter represents the HTML text content of the current element $('P'). HTML (function(index, oldhtml) {return 'Section' + (++index)+oldhtml; }); //-------------------------------jquery text () [plain text, do not parse HTML tags] //1. No parameter text (): Gets the contents of the [all matching] element, the result is a text that is composed of the text content contained by the [all matching] element, and returns a string varphtml= $('P'). text (); Console.log (phtml); //2. Parameter text (val): Sets the contents of the [all matching] element, the included HTML tag will not be parsed $('P'). Text ('<b> new </b>text with demo') //3. The parameter is the HTML of the callback function (funtion (index, HTML) {...}): The first parameter represents the index position of the current element (index starts at 0), and the second parameter represents the HTML text content of the current element $("P"). Text (function(index,oldtext) {return (++index)+ "." +OldText; }); //-------------------------------the Val of jquery () //1. Returns the first of the matching elements in a collection varival= $('Input:text'). Val (); Console.log (ival); //2. Set value values for all matching elements $('Input:text'). Val ('the account and nickname are duplicated! '); $('Input:text'). EQ (0). Focus (function(){ $( This). Val ("'); }); $('Input:text'). EQ (0). Blur (function(){ $( This). Val ($ ('Input:text'). EQ (1). Val ()); }); }); </Script></Head><Body> <P>Presentation text for the first P element</P> <P>Presentation text for the second P element</P>Account Number:<inputtype= "text"value= "Jason">Nickname:<inputtype= "text"value= "Rocky God Sticks"></Body></HTML>
Html,text,val of JQ