javascript - Which selector to use? -
I want to access the input tag or square of input through JS as selector so that I can reach next keyboard. The input element through the arrow It is not accessible by mentioning the name of the class, but after removing all the tags except the input tags and it works by inserting 'input' as the selector, such as
but when I It is not accessible with the name of the class
This is my
use code:
& lt; Table id = "foo" & gt; & Lt; TR & gt; & Lt; Td height = "30px" & gt; & Lt; Input type = "text" class = "nav_class" value = "" & gt; & Lt; / TD & gt; & Lt; Td height = "30px" & gt; & Lt; Input type = "text" class = "nav_class" value = "" & gt; & Lt; / TD & gt; & Lt; Td height = "30px" & gt; & Lt; Input type = "text" class = "nav_class" value = "" & gt; & Lt; / TD & gt; & Lt; Td height = "30px" & gt; & Lt; Input type = "text" class = "nav_class" value = "" & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Script & gt; $ (". Nav_class") keydown (function (e) {if (e.keycode == 40) {warning ('a'); $ (this) .next (". Nav_class"). Focus ();}} ); & Lt; / Script & gt;
That's because the inputs are wrapped in TD. You need to use:
$ (this). Parent (). Next () Find (". Nav_class") Focus (); Full code: $ (". Nav_class") key down (function (e) {if (e. Key code == 40) {Warning ('A'); $ (this) .Parent (). Find next (). (". Nav_class") Focus ();}});
Comments
Post a Comment