Cheok Yan Cheng Cheok Yan Cheng - 1 year ago 127
Javascript Question

How to use JQuery to select the nth option

I have the following HTML

<select onchange="this.form.submit()" name="name">
<option value="9995101E01#17201044055PM">9995101E01#17201044055PM</option>
<option value="GRR-Example">GRR-Example</option>
<option value="admin">admin</option>
<option value="123w">123w</option>

May I know how I can use JQuery to option with value "admin"?


Answer Source
$('select[name=name] option:eq(2)').attr('selected', 'selected');


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download