$ ("input[id^= ' str ']"). each (function () {});
the value and assignment of JQuery radio
Using regular expression instances in the jquery selector
function SelectAll (checked) {//starts with SSSS and ends with XXXX $ (": checkbox[id^= ' ssss '][id$= ' xxxx ']"). each (function () {$ (this). TR ("Checked", checked); }); Start with ssss or End with XXXX $ (": checkbox[id^= ' ssss '],[id$= ' xxxx ']"). each (function () {$ (this). attr ("Checked", checked); });}
jquery implements the value and assignment of the Select drop-down box, setting the selected method Daquan.
$ (". Selector"). Val ("Pxx"); $ (". Selector"). Find ("option[text= ' Pxx ']"). attr ("selected", true); $ (". Selector"). Val () ; $ (". Selector"). Find ("option:selected"). Text ();
1. Determine if there is a value= "Paravalue" Item function Jsselectisexititem (Objselect, Objitemvalue) {var isexit = False in the Select option) R (var i = 0; i < objSelect.options.length; i++) {if (Objselect.options[i].value = = objitemvalue) {Isexit = true; bre Ak }} return isexit; }//2. Add an item function Jsadditemtoselect (Objselect, Objitemtext, Objitemvalue) to the Select option {//To determine if there is an if ( Jsselectisexititem (Objselect, Objitemvalue)) {alert ("The value of the item already exists")} else {var varitem = new Option (Objitemtext, O Bjitemvalue); ObjSelect.options.add (Varitem); Alert ("Join successfully"); }}//3. Remove an item function Jsremoveitemfromselect (Objselect, Objitemvalue) from the Select option {//To determine if there is an if (Jsselectisexititem ( Objselect, Objitemvalue)) {for (var i = 0; i < objSelect.options.length; i++) {if (Objselect.options[i].value = = Obji Temvalue) {objSelect.options.remove (i); break;}} Alert ("delete successfully"); } else {alert ("The item does not exist in this select");}} 4. Delete the selected item in select Function Jsremoveselecteditemfromselect (objselect) {var length = Objselect.optioNs.length-1; for (var i = length; I >= 0; i--) {if (objselect[i].selected = = True) {Objselect.options[i] = null;}} 5. Modify the text of value= "Paravalue" in the Select option to "Paratext" function Jsupdateitemtoselect (Objselect, Objitemtext, Objitemvalue) {//To determine if there is an if (Jsselectisexititem (Objselect, Objitemvalue)) {for (var i = 0; i < ObjSelect.options.lengt H i++) {if (Objselect.options[i].value = = objitemvalue) {objselect.options[i].text = Objitemtext; break;}} alert ("Successful modification") ; } else {alert ("The item does not exist in this select");}} 6. Set the first item of text= "Paratext" in Select to check function Jsselectitembyvalue (Objselect, Objitemtext) {//To determine the existence of var isexit = False for (var i = 0; i < objSelect.options.length; i++) {if (Objselect.options[i].text = = Objitemtext) {objselect.options[ I].selected = true; Isexit = true; Break }}//show out the result if (isexit) {alert ("selected successfully");} else {alert ("The item does not exist in this select");}} 7. Set the item for value= "Paravalue" in Select to Document.all.objSelect.value = objitemvalue;//8. Gets the value Var of the currently selected item of select CurrsElectvalue = document.all.objselect.value;//9. Gets the text var currselecttext of the current selected item of select = document.all.objselect.options[document.all.objselect.selectedindex].text;//10. Gets the index var of the current selected item of select Currselectindex = document.all.objselect.selectedindex;//11. Clears the item for select document.all.objSelect.options.length = 0;
"jquery" jquery basic operations