Val (), append (), get (), split (), substr (), each (), html (), keyup (), trim (), show (), hide (), indexOf ()
One by one:
Val (): To evaluate and assign values to a page element.
Value: var result = $ ("# txtSearch"). val ();
Value assignment: $ ("# txtSearch"). val (result );
Each (): calls the following methods for Each element in a set for operations on a set, for example:
$. Each (data. list, function (I, item ){
Alert (item ["WikiTitle"] "+" item ["WikiID"]); // I is the following table of elements in the set. item represents the element itself.
});
Append (): Append an element to the specified page Element
For example, a list element <li> test! </Li>. Page elements like this can be dynamically added using the append method. For example:
The page contains a div with id = "div_keycontent": <div id = "div_keycontent"> </div>
In Js, you can write as follows:
$. Each (data. list, function (I, item ){
$ ("# Div_keycontent "). append ("<li>" + item ["WikiTitle"] + "<a href = \" Read/"+ item [" WikiID "] +" \ "> View </ a> "+" </li> ");
});
Get (): Get Data asynchronously on the page. This method is in the form of asynchronous binding. I have explained it in my previous article. I will not talk about it here.
Spilt (): perform the following operations on strings:
Var str = spit ("liu, ming, feng ",",");
The returned str is a string array: {"liu", "ming", "feng "}
Substr (); for string operations, remove the sub-string
Usage:
/// Determine 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 (): modify the content of an html Tag, for example:
$ ("# Div_keycontent" pai.html ("<p> no data </p> ");
Keyup (); trigger by pressing the keyboard
$ ("# TxtSearchKey"). keyup (function (){
$ ("# Div_keycontent" pai.html ("<p> data retrieval... </p> ");
});
Trim (): removes spaces at the beginning and end of a string.
Usage: str. trim ();
Show (): Display page elements, for example, $ ("# txtSearchKey"). show ();
Hide (): Hiding page elements such as: $ ("# txtSearchKey"). hide ();
Indexof (): Check whether the corresponding substring exists in the string.
Usage:
If (str. indexOf (',,')! =-1 | str. indexOf (',,')! =-1) {// determines whether a comma exists.
Alert ("two commas are used together !");
}