Val (), append (), get (), Split (), substr (), each (), HTML (), KeyUp (), Trim (), show (), Hide (), indexOf ()
One by one:
Val (): To take a value and assign a page element
Value: var result = $ ("#txtSearch"). Val ();
Assignment: $ ("#txtSearch"). Val (result);
Each (): the operation of a set, followed by a method call to each element within the collection, for example:
$.each (data.list, function (I, item) {
Alert (item["Wikititle"] "+" item["wikiid");//i is the element of the collection. The following table, item represents the element itself
});
Append (): Append elements after the specified page element
For example, a list element <li>test!</li>, a page element like this can dynamically add multiple <li> items through append methods such as:
The page has a id= "div_keycontent" div: <div id= "Div_keycontent" ></div>
JS inside can be written like this:
$.each (data.list, function (I, item) {
$ ("#div_keycontent"). Append ("<li>" + item["Wikititle"] + "<a href=\" read/"+ item[" wikiid "] +" \ "> View </a& gt; "+" </li> ");
});
Get (): On the page asynchronously fetch data, this way is the form of asynchronous binding, in my previous article has confessed, here will not say it.
Spilt (): Manipulating Strings for example:
Var str = Spit ("Liu,ming,feng", ",");
This returned STR is an array of strings: {"Liu", "Ming", "Feng"}
Substr (); string manipulation, going inside the substring
Usage:
Determines whether the last character is a comma
if (str.substring (str.length-1, str.length) = = "," | | str.substring (STR.LENGTH-1, str.length) = = ",") {
Alert ("The last character is a comma!") ”);
}
HTML (): Modifies the contents of an HTML label, for example:
$ ("#div_keycontent"). HTML ("<p> no Data </p>");
Keyup (); the keyboard presses the Bouncing Trigger method
$ ("#txtSearchKey"). KeyUp (function () {
$ ("#div_keycontent"). HTML ("<p> ....</p> in Data Retrieval");
});
Trim (): Remove the trailing space of the string
Usage: Str.trim ();
Show (): Let the page element display for example: $ ("#txtSearchKey"). Shows ();
Hide (): Hides the elements of a page for example: $ ("#txtSearchKey"). Hide ();
Indexof (): see if there is a substring in the string
Usage:
if (Str.indexof (',,, ')!=-1 | | str.indexof (',,, ')!=-1) {///Determine whether there are even commas
Alert ("With two commas!") ”);
}