I'm trying to insert the number only from this:
<span class="fb-comments-count" data-href="http://example.com/"></span>comments
into some existing php code:
<span class="meta_facebook_comments">
<i class="fa fa-comments"></i>
<?php
echo "Comments";
?>
</span>
and for the love of life I can't figure it out?
i.e. to display something like this:
<i class="fa fa-comments"></i> 2 Comments
for example..
looking for some advice, Thanks
You can use jquery prepend
to add value before "comments" text:
$(".fa .fa-comments").prepend("2 ");
The results will be
2 comments
EDIT: based of OP's comment-> to transfer data from one element to another, use this method:
var number_of_comments = $(".fb-comments-count").text(); //get number of comments
$(".fa .fa-comments").prepend(number_of_comments); //add comment count to another element
Please see this working demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With