Roland Roland - 1 year ago 92
jQuery Question

Remove value of input using jQuery

I need to remove some values from a hidden and text input box using jQuery, but somehow this is not working


<input type="hidden" value="abc" name="ht1" id="ht1" />
<input type="text" name="t1" id="t1" />

I use the following jQuery code to remove the values with an onclick event

$('#rt1').click(function() {

Can I empty the contents of the input box and clear the value of the hidden field using jQuery?

Answer Source
$('#rt1').click(function() {
    $('#t1').attr('value', '');  
    $('#ht1').attr('value', '');  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download