I’m learning jQuery, but am a bit stumped with this one. I have the following HTML:
...
<h1 class="myClass">First Part<br />Second Part</h1>
...
I can isolate this element from downloaded data using:
$(data).find("h1.myClass");
What I want to extract is the “First Part” bit. I assumed I could do this:
$(data).find("h1.myClass:first-child").text();
However, this results in an empty string. After doing a lot of searching, I am still unsure what I’m doing wrong here. Any help would be greatly appreciated.
Thanks!
$(".myClass").text().split("<br />")[0];EDIT:
Referrence correction comment: @box9