I have this code
<input type="checkbox"/>
<span>Foobar</span>
<input type="radio" checked="checked">Foo
<input type="radio">Bar
How to get the text Foo with jQuery where $(this) is the node <input type="checkbox"/>?
I can get the <input type="radio" checked="checked"> with $(this).parent().find(":checked").not($(this)) but I don’t know how to have the text.
Once you get to the target element…
use
[0]to get the DOM element at the first index from the jQuery object,use
nextSiblingto get the text node,use
datato extract the text content.or