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 in Web Development by gaurav
• 17,400 points
7 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 by rajatha
• 7,040 points

Related Questions In Web Development

0 votes
1 answer

jQuery get value of selected radio button

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

answered Jun 23 in Web Development by rajatha
• 7,040 points
49 views
0 votes
0 answers

Jquery Setting Value of Input Field

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

Jul 1 in Web Development by rajatha
• 7,040 points
11 views
0 votes
1 answer

How to set selected value of jQuery Select2?

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

answered 6 days ago in Web Development by rajatha
• 7,040 points
8 views
0 votes
1 answer

jQuery .val() vs .attr("value")

There is a big difference between an objects properties and an ...READ MORE

answered 6 days ago in Web Development by rajatha
• 7,040 points
6 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
187 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
599 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,500 points
306 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,740 points
280 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 in Web Development by rajatha
• 7,040 points
19 views
0 votes
1 answer

jQuery get value of select onChange

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

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