Really simple question. Why doesn't
<div class="plus-button" onclick="voteUp(' . $postid . ')" data-postid="' . $postid . '" name="like">+ ' . $voterow['totalupvotes'] . '</div>
work with
<script type="text/javascript">
function voteUp(postid){
var postid = postid;
$(this).siblings('.minus-button').removeClass('disliked');
$(this).toggleClass('liked');
$.ajax({
type:"POST",
url:"php/votesystem.php",
dataType : 'html',
data:'act=like&postid='+postid,
success: function(data){
$('.plus-button').html(data);
alert("Liked with id "+postid);
}
});
}
</script>
The div line works fine. The problem is that $(this) in the java/jq script is not recognized as a specific div class.
I have tried using voteUp(this) and didn't get it to work. Also tried using
var postid = $(this).data('postid');
but my alert msg then says undefined id instead of whatever id it should be.