Selecting all descendants of currently selected element.
Hi all,
I'm new to jQuery and I'm trying to write some code to hopefully fix ie6 issues with forms and buttons (you know the kind)... It's very rudimentary, and it doesn't work yet... My question is "what is the best way to select all descendant elements of the currently selected element, so that I can bind click() events to the relevant buttons?" Here's the code:
-
/*
* Only include this if browser is IE6
*/
$(document).ready(function(){
$("form").each(function(){ // For each form:
form = $(this);
// For each 'submit' button within that form:
// make it a regular (non submit) button
// Bind a click event to it to:
/* Below is the line I'm confused about */
form.children().find(":button").click(function(){
innerhtml = $(this).html(); // save it's innerHTML
$(this).html($(this).val()); // move it's 'value' attribute into it's innerHTML
form.find(":button").not(this).each(function(){ // disable all other buttons
$(this).attr("disabled", "disabled");
});
form.submit();// submit the form
form.children().find(":button").not(this).each(function(){ // enable the disabled buttons
$(this).removeAttr("disabled");
});
$(this).html(innerhtml); // restore it's innerHTML
});
});
});
Please point me in the right direction, I want to know the kosher way of accomplishing this