Below is a jQuery selector that works, and the value is set correctly into the text box. Why doesn’t the XPath code within the jQuery selector work? I thought jQuery supported XPath.
jQuery code working:
$('html > body > form > div:nth-child(4) > label > input').val('hello world');
jQuery code not working:
$('/html/body/form/div[4]/label/input[1]').val('hello world');
Documentation here:
http://docs.jquery.com/DOM/Traversing/Selectors
… search for this code in the documentation above …. $("/html/body//p")
jQuery does not support XPath syntax for selectors out of the box anymore.
If you look at that documentation you link to, you’ll see it’s for version 1.1.2, something from more than 5 years ago. It also says, in a great big red box with centered text: