I am using a form and a reset button where I can reset all the entered values but it is not working at all.
When I debugged with the Firefox console tab, I saw an error illegal character at the end of the jQuery script. Can someone tell me what is the wrong part here?
<!DOCTYPE HTML>
<html lang="en-IN">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery1.7.2.js"></script>
</head>
<body>
<script type="text/javascript">
jQuery('#reset').click(function(){
$(':input','#myform')
.not(':button, :submit, :reset, :hidden')
.val('')
.removeAttr('checked')
.removeAttr('selected');
});
</script>
<form id='myform'>
<input type='text' value='test' />
<select>
<option>One</option>
<option selected="true">Two</option>
</select>
<select multiple="true" size="5">
<option>One</option>
<option selected="true">Two</option>
</select>
<input type='button' id='reset' value='reset' />
</form>
</body>
</html>
Try the following:
You’re running the javascript before the DOM is ready.
$(function() {})only runs when the DOM is ready. Read more here:.ready()