Asp + Jquery Focus Next Textbox From Gridview
I have a gridview with a table. Inside this table we have a few labels and textboxes.  I am currently trying to switch from textbox to the next one when the user presses enter. For
Solution 1:
This should work. Basically you have to find the next <td> first and then the TextBox within it.
<scripttype="text/javascript">
    $('.mGrid input[type=text]').keypress(function (e) {
        if (e.keyCode == 13) {
            //eerst de td vinden ipv $(this).next anders werkt het niet
            $(this).closest('td').next('td').find('input[type=text]').focus();
        } else {
            return;
        }
    });
</script>Tested with this GridView
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="false"CssClass="mGrid"><Columns><asp:TemplateField><ItemTemplate><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:TextBoxID="TextBox2"runat="server"></asp:TextBox></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:TextBoxID="TextBox3"runat="server"></asp:TextBox></ItemTemplate></asp:TemplateField></Columns></asp:GridView>
Post a Comment for "Asp + Jquery Focus Next Textbox From Gridview"