Internet explorer, jQuery: input box jumps/moves when being replaced with the exact same one -


What do I want : To focus, change one input box to another ()

What do I get : In Internet Explorer (7/8), the input box runs some pixels on the right while focusing.

  • Works well in other browsers (obviously).

Here's a link where I've rebuilt this problem:

& lt; The link has now been removed due to beeing

The source is available in the above file, but I will also include it here for your convenience.

  & lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Meta http-equiv = "content-language" content = "n" /> & Lt; Script src = "include / jquery-1.4.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("# index_login_dummy") Focus (function () {$ (this) .hide (); $ ('# index_login_dummy2'). Show (). Focus ();} );}); & Lt; / Script & gt; & Lt; Style type = "text / css" & gt; .input_h {display: none;} & lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "index_login" & gt; & Lt; Form method = "post" name = "index_login" action = "login.php" & gt; & Lt; Input id = "index_login_email" type = "text" value = "email" name = "email" & gt; & Lt; Input id = "index_login_dummy" type = "text" value = "password" name = "dummy" & gt; & Lt; Input id = "index_login_dummy2" type = "text" class = "input_h" value = "password" name = "dummy" & gt; & Lt; Input type = "submit" class = "input_button" value = "login" & gt; & Lt; / Form & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

+1 for a well-designed question! ;)

Edit:

When I put the form field in a table, it intends to make me think that sometimes you have to go with it with a solution , But I do not know why, though, I am fine with the explanation that different browsers drag the input elements individually (and that the input button in IE affects the rest of the elements).

Working code:

  & lt; Div id = "index_login" & gt; & Lt; Form method = "post" name = "index_login" action = "login.php" & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input id = "index_login_email" type = "text" value = "email" name = "email" & gt; & Lt; / Td> & Lt; Td> & Lt; Input id = "index_login_dummy" type = "text" value = "password" name = "dummy" & gt; & Lt; Input id = "index_login_dummy2" type = "text" class = "input_h" value = "password2" name = "dummy"> & Lt; / Td> & Lt; Td> & Lt; Input type = "submit" class = "input_button" value = "login" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt; / Div & gt;  

I think the problem here is that between the "index_login_dummy2" text box There is no difference and submit button if you change your .input_h style to display: inline, then you should see the problem.

A solution is to apply a margin to the right of the "index_login_dummy2" box.

  .input_h {display: none; Margin-right: 4px; }  

should do the trick


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -