im creating a blog post where onclick 'like' it finds the class for the number of likes and adds plus one to it. i think i can do this with parse int.. can anyone help me with this >
That is the HTML
<span class="button_class"><a class="lik_right_stat_like" href="javascript:;">4255 Likes ·</a></span>
This is the javascript.. onclick like works fine.. having trouble parsing the value for the above class and adding one to it. This is the jquery
$(this).parent("div").find(".lik_right_stat_like").attr("alt", count) parseint()++;
(im quite new to jquery)
Try
$('.button_class').click(function () {
$(this).parent("div").find(".lik_right_stat_like").text(function (idx, text) {
return $.trim(text).replace(/^(\d+)/, function (str) {
return (parseInt(text.match(/^(\d+)/), 10) || 0) + 1;
});
});
});
Demo: Fiddle
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.