I have been using the following code to add some extra text onto a dropdown option:
jQuery("[id='product option1'] > option:contains('Notebook')").text('Notebook - OUT OF STOCK');
I have to get the option by it's Text as 1000's of my products use this same dropdown and they each have their own different value. It is just the text that is the same for all.
This works but also in my dropdown list is Notebook Large
so using the above adds - OUT OF STOCK
to any options with the words Notebook.
I know this is because I am looking for contains
. What can I use to find the option with the exact text only?
note: I know it is not best practice but I cannot change the id to not have spaces hence the need for [id='product option1']
as the selector.