I assume that the #chapter is a <select> or one of its ancestors.
If this is the case, remove the context argument.
$('#chapter option:selected').removeAttr('selected') .next('option').attr('selected', 'selected');
How you did it, you really did it:
$('select').find('#chapter option:selected').removeAttr(...
... that searches for an element inside <select> that has option:selected , descending from the element with the identifier chapter .
EDIT: This answer focused only on why the choice didn't work. It would be better to complete the final task using the method in @Andy E answer .
I would recommend this as an accepted answer.
source share