When I process HTML form elements using jQuery, I always get an ugly combination of jQuery syntax and plain JavaScript, for example:
function doStuff($combo){
if( $combo.get(0).options[$combo.get(0).selectedIndex].value=="" ){
var txt = "";
}else{
var txt = $combo.get(0).options[$combo.get(0).selectedIndex].text;
}
var $description = $combo.closest("div.item").find("input[name$=\[description\]]");
$description.val(txt);
}
Are there standard jQuery methods for handling typical operations on elements such as <select>, <input type="radio">and <input type="checkbox">?
With typical, I mean things like reading the value of the selected radio button in a group or replacing items in a select list. I did not find them in the documentation, but I admit that overloading the method can make the doc browser more difficult.
Update
Thanks to everyone. Once on the right track, I realized that the rest. For example, I can process the list <select>like any other DOM tree:
$("select")
.empty()
.append('<option value="">(Pick one)</option><option value="a">Option A</option><option value="b">Option B</option>');