is there any simple way to keep cursor in an input element when I move the element across DOM?
Example: http://jsfiddle.net/y1nu1q4f/1/
<form>
<input type='text' name='a' /> ho ho ho
<input type='text' name='b' /> merry christmas
</form>
<script>
setTimeout(function(){
$('input[name="a"]').appendTo($('form'));
$('input[name="b"]').appendTo($('form'));
}, 3000);
</script>
This example moves the text input after 3 seconds. When the input is focused (cursor is inside), it loses focus when moved. Is it possible to keep/return the cursor to its original position?
In my app I have many inputs in a form which's DOM is being reorganized like this, so I need some simple and flexible solution, not putting bunch of extra attributes and code for each input. jQuery solution is preferred to pure javascript.
Thanks in advance for answers.