I have an automated <li>
list created in my page with some text as link:
<ul class="continents">
<li class="link"><a href="#">hotels in USA</a></li>
<li class="link"><a href="#">hotels in Europe</a></li>
<li class="link"><a href="#">hotels in Asia</a></li>
<li class="link"><a href="#">hotels in Africa</a></li>
</ul>
I want to remove only the "hotels in "
from the links. can I do it with jquery?
Try .text( function(index, text) )
$('.continents a').text(function (_, old){
return old.replace('hotels in ', '');
});
try this
$(".continents li>a").each(function () {
console.log($(this).html().replace('hotels', ''));
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.