1.javascript Array Usage
Method |
Description |
FF |
IE |
Concat () |
Joins two or more arrays and returns the result. |
1 |
4 |
Join () |
Put all the elements of the array into a string. element is delimited by the specified delimiter. |
1 |
4 |
Pop () |
Delete and return the last element of the array |
1 |
5.5 |
Push () |
Adds one or more elements to the end of the array and returns the new length. |
1 |
5.5 |
Reverse () |
Reverses the order of the elements in the array. |
1 |
4 |
Shift () |
Delete and return the first element of the array |
1 |
5.5 |
Slice () |
Returns the selected element from an existing array |
1 |
4 |
Sort () |
Sorting elements of an array |
1 |
4 |
Splice () |
Deletes the element and adds a new element to the array. |
1 |
5.5 |
Tosource () |
Returns the source code for the object. |
1 |
- |
ToString () |
Converts the array to a string and returns the result. |
1 |
4 |
toLocaleString () |
Converts the array to a local array and returns the result. |
1 |
4 |
Unshift () |
Adds one or more elements to the beginning of the array and returns the new length. |
1 |
6 |
ValueOf () |
Returns the original value of an array object |
1 |
4 |
The above list is the JavaScript array object encapsulation, through the above method, you can easily and conveniently manipulate the object, reference URL: http://www.cnblogs.com/zyh-nhy/archive/2007/08/08/847876.html
2.checkbox
For a check box, there is generally a fixed process, many check boxes are due to a property, so usually use a TextBox or a Label object to store the value of a family check box, just need to set the TextBox or Label property to hidden. When a page is passed or gets a parameter, only the TextBox or label that operates the response is required.
For example:
<div id= "Crowd" class= "CHECKBOX_BGFL" >
<input name= "Crowd" type= "hidden"/>
<p><inputtype= "checkbox" value= "137"/><span> old man </span></p>
<p><inputtype= "checkbox" value= "138"/><span> Youth </span></p>
<p><inputtype= "checkbox" value= "139"/><span> children </span></p>
</div>
The check box family is to select the appropriate crowd, in the JS operation as follows:
Var crowd=[],//declares an array of access check box values
$ ("#crowd input:checkbox:checked"). each (function () {
Crowd.push (This.value);
});//traverse check box to save the selected value in the crowd array
$ ("#crowdinput: Hidden"). Val (Crowd.join (","));//Extract the value from the crowd array, and string the values into a string, separating the values from the values with commas.
For example, if the old and children are selected, the parameter format is as follows: ...? crowd=137,139
3.select
The operation of select in jquery is relatively straightforward, but you can add option items dynamically through the Append () function.
For example, there is a select control on the page as follows:
<select id= "Crowd" name= "crowd" >
<optionvalue= "-1" > Please select </option>
</select>
The JS code looks like this:
var crowd= "Old person 137, youth 138, children 139"; Array of option strings
Crowd=crowd.split (",");//String segmentation
vartemp=$ ("#crowd");//Gets the object in the page
$each (Crowd,function () {//Traversal option string
var value=this.split (""); To continue separating the options string
Temp.append ($ ("<option/>"). html (value[0]). attr ("value", value[1]);//Add option
});
At this point, the initialization of the Select option is complete, because the control is used in most cases as a single value, so the acquisition of form values does not need to be written again
In addition, the most important event for select is the number of onchange, just add the onchange event declaration to the page and then work in jquery.
4. String functions
String packaging is a very important application in many languages, because it is very practical, the use probability is very high, JS is no exception, the string is a series of encapsulation, the specific method is as follows:
Method |
Description |
FF |
IE |
Anchor () |
Creates an HTML anchor. |
1 |
3 |
Big () |
Displays the string in a large font. |
1 |
3 |
Blink () |
Displays the flashing string. |
1 |
|
Bold () |
Use bold to display the string. |
1 |
3 |
CharAt () |
Returns the character at the specified position. |
1 |
3 |
charCodeAt () |
Returns the Unicode encoding of the character at the specified position. |
1 |
4 |
Concat () |
The connection string. |
1 |
4 |
Fixed () |
Displays the string as a typewriter text. |
1 |
3 |
FontColor () |
Displays the string using the specified color. |
1 |
3 |
FontSize () |
Displays the string using the specified dimensions. |
1 |
3 |
fromCharCode () |
Creates a string from character encoding. |
1 |
4 |
IndexOf () |
Retrieves a string. |
1 |
3 |
Italics () |
Use italic to display strings. |
1 |
3 |
LastIndexOf () |
The string is searched forward from the back. |
1 |
3 |
Link () |
Displays the string as a link. |
1 |
3 |
Localecompare () |
Compares two strings in a local-specific order. |
1 |
4 |
Match () |
Found one or more matches that are being expressed. |
1 |
4 |
Replace () |
Replace the substring that matches the regular expression. |
1 |
4 |
Search () |
Retrieves a value that matches a regular expression. |
1 |
4 |
Slice () |
Extracts a fragment of a string and returns the extracted part in a new string. |
1 |
4 |
Small () |
Use a small font size to display the string. |
1 |
3 |
Split () |
Splits a string into an array of strings. |
1 |
4 |
Strike () |
Use strikethrough to display strings. |
1 |
3 |
Sub () |
Displays the string as subscript. |
1 |
3 |
SUBSTR () |
Extracts a specified number of characters from the starting index number in a string. |
1 |
4 |
SUBSTRING () |
Extracts the characters between two specified index numbers in a string. |
1 |
3 |
SUP () |
Displays the string as superscript. |
1 |
3 |
toLocaleLowerCase () |
Converts the string to lowercase. |
- |
- |
toLocaleUpperCase () |
Converts the string to uppercase. |
- |
- |
toLowerCase () |
Converts the string to lowercase. |
1 |
3 |
toUpperCase () |
Converts the string to uppercase. |
1 |
3 |
Tosource () |
Represents the source code for the object. |
1 |
- |
ToString () |
Returns a string. |
- |
- |
ValueOf () |
Returns the original value of a string object. |
1 |
4 |
Citation URL: http://www.w3school.com.cn/js/jsref_obj_string.asp
5. As for the use of other controls in this first not to repeat, behind the use of writing, form elements after the completion of the form is submitted, before perhaps the use of HTML page common objects, such as request settings parameters, or directly following the address, regardless of how to deal with, have to write a lot of code, However, after using jquery, the work becomes unusually simple. The reason is the use of the Serialize () method.
Examples are as follows:
Html:
<form name= "Form1" Id= "Form1" method= "POST" >
<input type= ' text ' name= ' name ' value= ' John '/> <input type= ' text ' name= ' location ' value= ' Boston '/>< Button Name= "BT" click= "Btclick" ></form>jquery Code: <script type= "Text/javasctipt" > Function Btclick () { window.location.href=url+ "?" +$ ("#form1"). Serialize (); }</script>
Result:
Url?name=john&location=boston//Order Amount Information var $orderMoneyInfo = $ (' #track ' +orderid). Children (' TD '). EQ (3). Text (); //Split Amount and payment method copy var Moneyindex = $ Ordermoneyinfo.indexof ("."); var $moneyInfo = $orderMoneyInfo. substr (0, moneyindex+3); var $paymentWayInfo = $orderMoneyInfo. substr (moneyindex+3, $orderMoneyInfo. Length); var $contend = "<div id=\" mbz\ ">" + & nbsp; " <div class=\" m-text\ "><i class=\" bg-joy\ "></i>" + " <p class=\" ftx-04\ ">replacevalue </p> "+ " </div> "+ &NBSP; " <div class=\ "M minfo\" > "+ " <div class=\ "mt\" > Summary of common methods of jquery operation string and working code