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
2,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,640 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, 2022 in Web Development by rajatha
• 7,640 points
2,393 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,640 points
881 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,640 points
6,403 views
0 votes
1 answer

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

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

answered Aug 5, 2022 in Web Development by rajatha
• 7,640 points
821 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
512 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
987 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,510 points
973 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,880 points
827 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,640 points
407 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,640 points
848 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