Is there a clever jQuery selector for selecting a text node like this:
<div><input type="text">one <span>two</span> three</div>
I would like to get three from the markup above and wrap it in a strong tag like this:
<div><input type="text">one <span>two</span> <strong>three</strong></div>
Here is how to select text nodes using jQuery:
In your example x will then contain ‘one’ at index 0 and ‘three’ at index 1. Like Keith Rousseau said, you can’t really just grab that text, but if you know it will be last you can get it like this:
You can also add the strong tag like this:
This questions describes selecting text nodes with jQuery (my first code snippet).