Reputation: 34170
All,
I have a text area field in my for,.How do i clear contents of it on sum onclick using jquery
Thanks.
Upvotes: 0
Views: 948
Reputation: 68680
This will clear the default value onclick and restore back onblur.
$('textarea').click(function () {
if (this.value == this.defaultValue) {
this.value = '';
}
});
$('textarea').blur(function () {
if (this.value === '') {
this.value = this.defaultValue;
}
});
Upvotes: 2
Reputation: 108500
$('textarea').focus(function() {
$(this).val('');
});
This will clear the textarea on focus (using mouse click or keyboard).
Upvotes: 3
Reputation: 10685
$("#textArea").click(function(){ $(this).attr({ value: '' }); });
With a couple of caveats:
Upvotes: 3