jquery - Prevent 'caret' jumping on focus -


so, i'm trying replicate html5 'placeholder' attribute functionality.

one thing i'm stuck on is, upon focus of element, caret appearing @ start of input.

as stands, caret appears in position user clicks , jumps start when use jquery move it.

look here: http://www.dollmode.com/test - click on "desired username" field , see mean.

any workarounds?

edit 1 idea had placing empty input on top of either text or input. way, when user typed empty input, text in background wouldn't select-able , hidden upon entering text empty input. there cross-browser (back ie6) doing this?

1.you have remove text inside textbox when gets focused

$("input[type=text]").focus(function(){   $(this).val(''); }); 

2.then when focus lost have check whether user filled textbox if textbox empty should assign placeholder value

$("input[type=text]").blur(function(){     if($(this).val()=='')             $(this).val()= $(this).attr('title');          }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -