zod zod - 1 year ago 109
jQuery Question

$("#select option:second").val() jquery - keep select second value of select box option

I am able to keep select the first and last value of a select box

$("#selbox").val($("#sel_selbox option:last").val());

$("#selbox").val($("#selbox option:last").val());

How can i keep select the second value ?

$("#selbox").val($("#selbox option:second").val());

THis is giving error. Is there any option to keep select by giving index ?

Answer Source

Yes, you want the special jQuery eq() selector.

    $("#selbox").val($("#selbox option:eq(1)").val());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download