I have some html extracted to a string var, and want to then use jQuery element selection just on that string. Is this possible?
For example:
HTML:
<div class=message>
This is a message. Click <a class=link id=link1 href=example.com>here</a>
</div>
jQuery:
$('div.message').each(function(i, item) {
myHtml = $(this).html();
//select <a> tag attributes here
)};
So in this example, I want to extract the id
and href
from the <a>
tag in myHtml
.
Thanks