I currently trying to change the color of the div when onclick the but fail , i using "postid" instead of using id and class cause it need to change the color of the div that onclick only
$(function () {
$('.like').click(function () { likeFunction(this); });
});
function likeFunction(caller) {
var postId = caller.parentElement.getAttribute('postid');
$.ajax({
type: "POST",
url: "rate.php",
data: 'Action=LIKE&PostID=' + postId,
success: function () {}
});
}
<div class="post" postid="10">
<input type="button" class='like' value="LikeButton" /> </input>
</div>
JavaScriptso far?data-*attributes instead?