if (tag == 'td' && $(this).hasClass('status')) {
// I am clearing everything inside the td with class status
$(this).html('')
}
But it doesn’t seem to clear… Any suggestion…
I am customizing a form plugin,
$.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form')
return $(':input', this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea' )
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
else if (tag == 'td' && $(this).hasClass('status')) {
// if you want to remove everything, use this
$(this).html('');
}
});
};
Looking at the code (in your edit), and assuming you call the function by doing something like
$('#myForm').clearForm()(wheremyFormis a form element), then its never going to processtdelements. The code takes a form & then recurses onto that form’s:inputelements to clear them. Given thattdis not aninput, they won’t be included in the clearing.If that is how you’re using it, you could customise it as follows to get it to clear your
tds (within the form) as well: