javascript - Get all inputs, selects and buttons and their order number in form using jQuery -
please see code:
<form id=form1> <input name="textbox1" type="text" value="1111111111" id="textbox1" /> <input name="textbox2" type="text" value="222222222" id="textbox2" /> <select name="dropdownlist1" id="dropdownlist1"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <input id="checkbox1" type="checkbox" name="checkbox1" /> <label for="checkbox1">nima</label> <input id="button1" type="button" value="button" /> </form>
i want command element in form using jquery order number.for example:
elementid order number -------------------------------- textbox1 1 textbox2 2 dropdownlist1 3 checkbox1 4 button1 5
how can this? thanks
it not hierarchy number, index.
$.each($('#form1').find('input, select'), function() { alert('index: ' + $(this).index()); });
or, if need consecutive numbers
$.each($('#form1').find('input, select'), function(counter) { alert('index: ' + counter); });
javascript jquery html
No comments:
Post a Comment