Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
148
rated 0 times [  150] [ 2]  / answers: 1 / hits: 33249  / 12 Years ago, thu, july 19, 2012, 12:00:00

I'm trying to create a button that can select next option.



So, i have a select (id=selectionChamp) with several options, an input next (id=fieldNext), and i try to do that :



$('#fieldNext').click(function() {
$('#selectionChamp option:selected', 'select').removeAttr('selected')
.next('option').attr('selected', 'selected');

alert($('#selectionChamp option:selected').val());
});


But I can not select the next option.. Thanks !


More From » jquery

 Answers
6
$('#fieldNext').click(function() {
$('#selectionChamp option:selected').next().attr('selected', 'selected');

alert($('#selectionChamp').val());
});


Better answer by @VisioN: https://stackoverflow.com/a/11556661/1533609


[#84155] Wednesday, July 18, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
colby

Total Points: 311
Total Questions: 102
Total Answers: 102

Location: Taiwan
Member since Mon, Sep 6, 2021
3 Years ago
;