[jQuery] Can find() return elements in DOM order?
Is there a way to make $.fn.find() return the elements in the order they appear in the dom instead of grouped by selector?<div>
</div><div>For example, let's say I have a form and I want to get the first form control, whether it's an input, select, or textarea. Here's some basic HTML:</div>
<div>
</div><div><form id="#myform"></div><div> <select>// ... //</select></div><div> <input type="text" /></div><div></form></div><div>
</div><div>I thought I could do this, but it's returning the wrong element:</div>
<div>
</div><div>var form_controls = $('form#myform').find('input, select, textarea');</div><div>console.log('first: ' + form_controls[0].tagName); // <-- first: INPUT, should be SELECT</div>
<div>
</div><div>Is there a way to get the desired effect with jQuery? Thanks!</div><div>
</div><div>-Hector
</div>