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 many Form1 forms, it doesn't matter, only the first one 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 child element of select
$ ("#select option:selected"). Text ()//if written as $ ("#select"). Text () Select all Drop-down menu Texts
2. Get and set the value of the Drop-down menu
$ ("#select"). Val ();//Fetch value
$ ("#select"). Val ("value");/setting, if there is an option in the select that has value, the option is selected, and if it does not exist, the 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", "");/Cancel Selection
$ ("#id [Value=val]"). attr ("checked", false);/Cancel Selection
$ ("#id [Value=val]"). Removeattr ("checked");/Cancel Selection
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")) {}//judgment selected
if ($ ("#id"). attr ("checked") ==true) {}//judgment selected
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")) {}//judgment not available
if ($ ("#id"). attr ("disabled") ==undefined) {}//judgment available