I’m using Facebook Comments with only access to HTML. No server side scripting.
My default output is “# Comments”.
<a class="comments" href="URL"><div class="fb-comments-count" data-href="URL"></div> Comments</a>
How can I use Javascript to make “Comments” turn into “Comment” if the number of comments in 1?
Thank you for your help!
Edit:
I’m using the standard Facebook Comments tag: https://developers.facebook.com/docs/reference/plugins/comments/
The outputted HTML is:
<a class="comments" href="URL"><div class="fb-comments-count" data-href="URL" fb-xfbml-state="rendered"><span class="fb_comments_count">4</span></div> Comments - Click to Add Yours</a>
I’d like to just say “Comments” if it’s 0, or anything above 1. And Comment if it’s 1.
you could use jQuery.length to count how many instances of the comments class exist and then if the number is 1 you could use jQuery.HTML to change the content of the div
so…