Is it possible to select text between
tags? I am working with the preformatted code below trying to select this data: New York, NY 10012
I've played around with $('#address').find('br').eq(2).text()
, but know that there must be a better way.
<div id="address">
Joe Dirt<br>
PO Box 842<br>
New York NY 10012<br>
800-555-5555<br>
<br>
</div>
Thanks!
Retrieve the HTML for the div
and split on the br
tag:
$.trim($("#address").html().split("<br>")[2]);
JS Fiddle: http://jsfiddle.net/KQgu5/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With