I have several tags like this:
<a class="classCover" href="#">1 Comment</a>
I would like to do this reversing the order of the words:
Comments (1)
My function is this but is not working:
$('.classCover').each(function(){
$(this).text().split(' ').reverse().join(' ');
});
Please, any idea?
You almost had it, except you're not doing anything with the result
$('.classCover').each(function(){
$(this).text($(this).text().split(' ').reverse().join(' '));
});
try this.
$('.classCover').each(function(){
var link = $(this).text().split(' ');
$(this).text(link[1] + "(" + link[0] + ")");
});
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.