I have anchor text that can look like "1 Reply and 30 Mentions" or "3 Replies and 1 Mention" (obviously with varying numbers). I'm trying to use jQuery to replace that anchor text with the added number.
$(document).ready(function() {
$('header div.comments-link a').each(function(index) {
var myreaction = $(this).text().split(" ");
$(this).text(myreaction[0]+myreaction[3]);
});
});
So for the first example, it would be 1+30 so the text replacement would be 31. For the second example, it would be 3+1 so the text replacement would be 4.
However, it doesn't appear to be replacing the actual text and doesn't seem to be doing the split array properly. As it's going down the page, it's sometimes grabbing "1" but other times grabbing "Reply".
Any ideas?