select option second val jquery - keep select second value of select box option

0 votes

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 ?

Jun 22, 2022 in Web Development by gaurav
• 23,260 points
3,354 views

1 answer to this question.

0 votes

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

    $("#selbox").val($("#selbox option:eq(1)").val());
answered Jun 22, 2022 by rajatha
• 7,680 points

Related Questions In Web Development

0 votes
1 answer
0 votes
1 answer

jQuery get value of selected radio button

Input Radio value Property Get the value of ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
2,711 views
0 votes
0 answers

Jquery Setting Value of Input Field

I have an input field and i ...READ MORE

Jul 1, 2022 in Web Development by rajatha
• 7,680 points
1,084 views
0 votes
1 answer

How to set selected value of jQuery Select2?

To set selected value of jQuery Select2 ...READ MORE

answered Aug 5, 2022 in Web Development by rajatha
• 7,680 points
6,994 views
0 votes
1 answer

How to use jquery with asp.net ajax?

If you weren't aware, Microsoft is planning ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
755 views
0 votes
1 answer

Is 'sparkline' a method?

I suggest you to check 2 things That jquery.sparkline.js is actually ...READ MORE

answered Nov 9, 2018 in Apache Spark by Frankie
• 9,830 points
1,278 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,324 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,840 points
1,096 views
0 votes
1 answer

jQuery get value of select onChange

Try this- $('select').on('change', function() { alert( this.value ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
581 views
0 votes
1 answer

jQuery get value of select onChange

To get the value and text of ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,680 points
1,116 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP