Reputation: 1118
I have dozen textboxes
on my form. On button click I need to clear some of them (not all) and if some conditions are satisfied, I need to restore values in textboxes
. How can I do that with less blood?
Upvotes: 1
Views: 371
Reputation:
This will manipulate your all input depending on condition but you have to call this method on your own
$("form").children("input").each(function(){
if(condition)
{$(this).val(this.defaultValue);
}
})
Upvotes: 1
Reputation: 32148
There is an .defaultValue
property which you can use like this:
txt.onblur = function() {
alert('restoring default value!');
this.value = this.defaultValue;
}
Upvotes: 0