Reputation: 105
<td class="ms-gb">
<a>
<span class="ms-commentexpand-iconouter">
<img class="ms-commentexpand-icon">
</span>
Mutual Funds
<img class="right-arrow">
</a> : Mutual Funds <span>(3)</span>
</td>
How can I get the anchor tag's HTML?
Upvotes: 0
Views: 104
Reputation: 10175
use this to get all html contents
$(".ms-gb a").html()
use this to get text of elements inside
$(".ms-gb a").text()
use this to get children in javascript object format
$(".ms-gb a").children()
Upvotes: 1
Reputation: 1096
just use the following line to get the html of a
var tempHtml = $('td.ms-gb > a').wrap('<div>').parent().html();
after unrap the a
by following line
$('td.ms-gb > a').unwrap('<div>');
Upvotes: 1
Reputation: 30557
Use html()
console.log($('a').html());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<td class="ms-gb">
<a>
<span class="ms-commentexpand-iconouter">
<img class="ms-commentexpand-icon"></span> Mutual Funds
<img class="right-arrow">
</a>: Mutual Funds <span>(3)</span>
</td>
Upvotes: 4