i have:
and
$(\'input\').blur(function(){
alert(\'stay focused!\');
});
You can get this behavior by calling preventDefault() in the mousedown event of the control being clicked (that would otherwise take focus). For example:
btn.addEventListener('mousedown', function (event) {
event.preventDefault()
})
btn.addEventListener('click', function(ev) {
input.value += '@'
input.setSelectionRange(ta.value.length, ta.value.length)
})
See live example here.