I have a bit of a strange question, I'm wondering whether this is at all possible.
I'm parsing the DOM and there is an element like this:
<!-- <a class="pager" title="next" href="www.text.com">NEXT</a> -->
I need to be able to select this element with jQuery and return its href
value. I've tried this:
$('a.pager[title="Next"]').attr('href');
but to no avail - from reading here Selecting HTML Comments with jQuery it seems that jQuery can only select elements with a particular nodetype
.
Is it possible to return the value www.text.com
from the HTML
element above? To make things a little more tricky, i need to do it without relying on jQuery plugins - native Javascript or plain jQuery only please.
The following code returns the whole comment (as well as the text contained in all other comments on the page):
$("*")
.contents()
.filter(function(){ return this.nodeType == 8;})
.each(function(){ alert(this.nodeValue);});
but I need to ONLY return the value of the a href
, and no other comments. Ideas?