I have multiple select boxes in my document and some of them are load with page load and some of them created dynamically. for example:
<select>
<option>select one</option>
</select>
<select></select>
<select>
<option>select two</option>
</select>
<select>
<option>select three</option>
</select>
<select>
</select>
and more are created dynamically some of with and some are empty.
I want to get the first empty select among them at page load and click on a button again want to get the first empty select box from the last one I get and continue this until no such select box further exists.
NOTE from the last one means,
If I get the first empty select box from first, then one button click search will start from that select box and continue until again get an empty select and so on.
Try this:
but one think to note that, above selector only works if your
selectbox are likebecause
:emptypoint element with no child, not event with newline or text node.So if your
selectis look like:above selector will fail. To get
selectlike both type you can useor as @gdoron mentioned
In my choice, second one is reliable.
Working Demo