trying to select next option drop down list by using a id identifier, but to no avail
here is the code
$('#chapter option:selected', 'select').removeAttr('selected').next('option').attr('selected', 'selected')
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume
#chapteris the<select>or one of its ancestors.If that’s the case, remove the context argument.
The way you had it, you were effectively doing this:
…which is looking for an element inside the
<select>that has anoption:selecteddescending from an elelent with thechapterID.EDIT: This answer was focused merely on why the selection wasn’t working. It would be better to accomplish the ultimate task using the method in @Andy E’s answer.
I’d recommend that one as the Accepted answer.