HTML code
<article class="evn-mn-pane">
<h2><a href="somelink.php">leborium</a></h2>
<div class="evn-date">20 June, 2013 | Dr.some name some name1</div>
<figure>
<img src="images/events/speakers/no-image.jpg" alt="Dr. Somename"/>
<figcaption>test link tested some dummy text this...
<a href="somlink.php">more</a>
</figcaption>
<div class="clear"></div>
</figure>
</article>
<article class="evn-mn-pane">
<h2><a href="somelink.php">leborium</a></h2>
<div class="evn-date">20 June, 2013 | Dr.some name some name1</div>
<figure>
<img src="images/events/speakers/no-image.jpg" alt="Dr. Somename"/>
<figcaption>test link tested some dummy text this...
<a href="somlink.php">more</a>
</figcaption>
<div class="clear"></div>
</figure>
</article>
Jquery code
$('article').each(function(){
alert($(this).find('figure > figcaption').html());
});
Result
test link tested some dummy text this...
<a href="somlink.php">more</a>
Expected Result
test link tested some dummy text this...
Tried Code
$('article').each(function(){
alert($(this).find('figure > figcaption').contents(':not(a)').html());
});
Getting Result
undefined
How to achieve the expected result?any helps are appreciated FYI: I am using jquery1.8.3
UPDATE
I want to take all other tags other then anchor tag, and expecting the result other then using clone method.
contentsdoesn't take any arguments. This works even if you add more text after thea.Updated JSFiddle
If you want every piece of text within
figcaptionexcept the text ina, use this:Regarding the
nodeTypepropertyMore on Node types