<input type="text" id="title" value="Write your post..." />
<input type="button" id="save_post" class="button" value="Submit" style="cursor:pointer;"/>
So I binded my enter key on my keyboard to do something, here it is:
$(document).keypress(function(e){
if (e.which == 13){
$("#save_post").click();
$("#save_post").focus();
}
});
Problem is, I want to shift focus as if I really was clicking the button, so that it takes the focus away from the text field (in which I also have a character counter for), and also takes the cursor out of that text field, but this isn’t working. Cursor stays in the field and the character counter still counts what you just submitted even though nothing is in the textbox anymore.
What am I doing wrong?
The following worked for me:
Demo: http://jsbin.com/izusem/2/edit