I have some asp textboxs in a div contain开发者_开发技巧er. I just want to clear those when i am clicking the CLEAR button.
I say common class 'text' for all textboxes and then wrote this jQuery
$(".text").text("");
It's not working ..
How to do this ? I need the most efficient code .
If you need to clear text boxes values alone, you can change the code like this:
$("#divID").find("input[type=text]").val('');
or
$("#divID").find("input:text").val('');
$('a.clearButton').bind('click', function() {
$('#divId input').val('');
});
Notes:
You should use val() instead of text().
You are asking for efficient code - and using class selector is not efficient.
Either use id, or add tag name.
$('#yourcontainerid input:checked').removeAttr('checked');
this will work successfully
$(':text').val("");
$('#ClearButton').bind('click',function(){
$('#div1').Find('input[type=text]').val('');
});
or
$('#ClearButton').bind('click',function(){
$('#div1').Find('input:text').val('');
});
精彩评论