The approach to use is to try and not include such elements in your selector.

Generall this means don’t hard code the entire selector (starting from body or some other elements) cos the page may change at some point. As you have discovered.

So in this case I would look to use the selector


This is not guaranteed to work. For example you might have both a label and an /anchor field that would both be selected using this. You could get around this either using an index, e.g.


or by adding an actual ID to the if you have access or ability to get the HTML itself changed, e.g.


As you can see the above would be the desirable way.

For all these approaches I would also use css which is easier to read and maintain IMHO, e.g.


Source link


Please enter your comment!
Please enter your name here