Remove the text of the selected item from the Pull menu; get and set the Drop-down menu value; Empty the Drop-down menu, add elements to the following menu, select the value of the checkbox, choose the Selection or check button, take the check box value, determine if the radio or check box is selected, make the element unavailable, and determine if the element is unavailable.
Practical jquery operation Form element code
/* Suppose there is a button in a form id= "save"
$ (document). Ready (function () {
$ ("#save"). Click (function () {
$ ("#save" ). attr ("Disabled", true);/set to Not available
$ ("#form1") [0].submit ();//If you have a lot of id Form1 form It doesn't matter, only the first will submit haha.
});
Remove the text of the selected item from the Pull menu;
Gets and sets the value of the Drop-down menu;
Empty the Drop-down menu;
Add elements to the following menu;
Take a single marquee value;
Selection of radio or check buttons;
Take the check box value;
Determines whether a single selection or check box is selected;
element is not available;
The decision element is not available.
1. Remove the text of the selected item from the Pull menu
$ ("#select option[selected]"). Text (),//select and option have spaces, option is the child element of select
$ ("#select option:selected"). Text ();//if written as $ ("#select"). Texts () Select all the Drop-down menus
2. Get and set the value of the Drop-down menu
$ ("#select"). Val ()//value
$ ("#select"). Val ("value")//setting, if there is an option in the select that has value values, the option is selected, and if not, select does not make any changes
3. Empty the Pull-down menu
$ ("#select"). empty ();
$ ("#select"). HTML ("");
4. Add elements to the following menu
$ (' <option value= "1" >1</option> "). Appendto ($ (" #select "));
$ ("#select"). Append (' <option value= ' 1 ">1</option> ');
5. Take a single marquee value
$ ("#id [checked]"). Val ();
6. Choice of radio or check button
$ ("#id [Value=val]"). attr ("Checked", true);//select
$ ("#id [Value=val]"). attr ("Checked", "");//deselect
$ ("#id [ Value=val] "). attr (" checked ", false)//deselect
$ (" #id [Value=val] "). Removeattr (" checked ");//deselect
7. Take check box value
$ ("input[type=checkbox][checked]"). each (function () {
alert ($ (this). Val ());
})
If you use $ ("input[type=checkbox][checked]"). Val (), only the first selected value is returned
8. Determine if a single selection or check box is selected
if ($ ("#id"). attr ("checked")) {}//is judged to select
if ($ ("#id"). attr ("checked") ==true) {}//determines
if ($ ("#id"). attr (" Checked ") ==undefined {}//judgment not selected
9. Elements available are not available
$ ("#id"). attr ("disabled", false);/set to Available
$ ("#id"). attr ("Disabled", true);//set to not available
10. Determine that elements are not available
if ($ ("#id"). attr ("Disabled")) {}//judge not available
if ($ ("#id"). attr ("disabled") ==undefined) {}//judge available
The above practical jquery operation form element Simple code is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.