Reset or Retrieve value of all hidden type input box of FORM or DIV using jQuery .each() method. You can use below code for this
<!DOCTYPE html>
<html>
<head>
<title>Reset or Retrieve value of all hidden type input box of FORM or DIV using jQuery .each() method...</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#testform").find('input:hidden').each(function () {
$(this).val('');
});
});
</script>
</head>
<body>
<form class="demo" id="testform" >
<input type="hidden" name="demo1" value="value1" />
<input type="hidden" name="demo2" value="value2"/>
<input type="hidden" name="demo3" value="value3"/>
<input type="hidden" name="demo4" value="value4"/>
<input type="hidden" name="demo5" value="value5"/>
</form>
</body>
</html>
In above example jQuery code execute on document ready state and find all the input of type hidden for the form of ID "testform" and iterate each inputs to assign empty or null value.
Yo can use this function on different events like onClick, onkeyup etc.
0 Comment(s)