html:
<div id="search">
<input id="term" type="text" value="enter your search" />
<button id="hit" type="button" name="">Search</button>
</div>
jQuery:
$(document).ready(function() {
var term = $('#term').val();
$('#hit').click(function() {
alert(term);
});
});
The problem is that , no matter what I type in the input field, then hit the button, it always alert the original input value which is "enter your search".
How can I fix it?