Can someone tell me what is happening, why my counter in id="love"
is not increasing when button with id="buttonattr"
is clicked, here's my code :
<button class="btn btn-default buttonattr"style="font-family:Pangolin" onclick="myhit(\''+this["post"]+'\',\''+this["love"]+'\');myclick()"><span class="glyphicon glyphicon-heart fa-lg notactive" ></span> Love</button><pre id="love">'+this["love"]+' students<i class="glyphicon glyphicon-heart fa-lg" style="color:red">
for script:
var toAdd=1;var newValue=0;
var overall=1;
function myhit(post,love){
oldValue=parseInt(love);
if(toAdd>0){
newValue= oldValue + toAdd;
}
else{
newValue=overall+toAdd;
}
toAdd *= -1;
overall=newValue;
$.post('porthome4_.php',{post1:post,love:newValue},function(info){});
}
function myclick(){
$('.buttonattr').click(function(){
$(this).find('#love').html(overall);
$(this).find('#love').append(' students<span class="glyphicon glyphicon-heart fa-lg "a style="color:red" ></span>');
});
}