Kênh Tên Miền chuyên cung cấp tên miền đẹp, giá rẻ! Hãy liên hệ kỹ thuật: 0914205579 - Kinh doanh: 0912191357 để được tư vấn, hướng dẫn miễn phí, Cảm ơn quý khách đã ủng hộ trong thời gian qua!
Saturday, December 27, 2014

Cach 1:

Doing this task with jQuery is really easy:
$('#FormID').each (function(){
this.reset();
});
The thing is, that the code above iterates through each element of the form, and calls to the DOM “reset” JavaScript method. In fact, the “reset” function does not exist in jQuery.
It would be much more simple to do something like $(“#FormID”).reset(). Fortunately creating that function in jQuery only will take a minute of programming:
jQuery.fn.reset = function () {
$
(this).each (function() { this.reset(); });
}
Using the code above, reseting a form would be just one call (as desired):
$("#FormID").reset();

Cach 2:

<input type="button" onclick="this.form.reset();">
Cach 3:

function reset(){
$
('input[type=text]').val('');
$
('#textarea').val('');
$
('input[type=select]').val('');
$
('input[type=radio]').val('');
$
('input[type=checkbox]').val('');
}

0 comments:

Post a Comment

Popular Posts