Insert cursor on click of a button
by Akram kamal
HTML
<a class="custom-newtopic-button">Create Topic</a>
<form class="bbp-topic-form">
<label>
<input name="foo">
</label>
<button>send</button>
</form>
CSS
.bbp-topic-form {
width: 300;
position: relative;
left: -300px;
transition: left 1s;
}
.bbp-topic-form.in {
left: 0;
}
JavaScript
jQuery('.custom-newtopic-button').click(function() {
jQuery(this).hide();
jQuery('.bbp-topic-form').addClass("in").find(":input:first").focus()
});
jQuery('.bbp-topic-form').submit(function() {
alert("submitting")
// you can use ajax here
jQuery(this).removeClass("in").prev().show();
return false;
})