Reputation: 55
Need help in event handling. In my scenario, I have a textbox with default value 35 and cursor is set to before the 3. There is a event for this text box which is onkeydown. When I press 4, IE and Safari captures the previous value of the text which is 35. But Mozilla and Chrome captures the new value which is 435.
I need the javascript code which can capture the previous value of the textbox when onkeydown is fired.
Need your hands :(
Upvotes: 1
Views: 171
Reputation: 3278
Tested in IE, Chrome, FF, Opera and it works
<div>
<input type="text" value="35" />
</div>
<script>
$("input").keydown(function () {
alert($(this).val());
});
</script>
Upvotes: 3