For example, I would like to append selected="selected" to the option that contains This one, which jQuery selector should be used to append attributes into that element?
<select>
<option>Not this</option>
<option>This one</option>
</select>
Thanks in advance!
If there are no
valueattributes, then the text becomes the value, so you can just use.val():Or, if it has a
value="something"attribute, use that instead: