I added a clickable image button near an image thumbnail but for some reason the image is not clickable and it doesn't pass any value to function it calls (postLike function). Here is an example in js fiddle:
Here is part of the code that has the clickable button:
<div id='like"+pageurl+"' style='float: right; padding: 5px 2px 2px;'>
<img class='liker' onclick=postLike("+imageurl+","+username+","+albumPicurl+","+userid+","+pageurl+","+time+","+text+") src='"+likeimage+"' border='0'>
</div>
Once the user click the button I want to change the button image and the function it calls to something different like below but it doesn't work. The code doesn't replace the image button:
$('like+e+').html(" <img class='lb-liked' onclick='deleteLikeLB("" + a + "","" + b + "","" + c + "","" + d + "","" + e + "","" + f + "","" + g + "")' src='http://www.peppertt.com/wp-2013/wp-content/uploads/2011/06/Facebook-like-not.jpg' title='like' border='0' />");
Code:
function postLike(a, b, c, d, e, f, g) {
alert("Hello World!");
alert("imageURL:" + a + "\nuserName:" + b + "\nalbumPicurl:" + c + "\nuserId:" + d + "\nPageURL:" + e + "\nTime:" + f + "\nText:" + g);
$('like+e+').html(" <img class='lb-liked' onclick='deleteLikeLB("" + a + "","" + b + "","" + c + "","" + d + "","" + e + "","" + f + "","" + g + "")' src='./liked.png' title='like' border='0' />");
}
var imageurl = "http://upload.wikimedia.org/wikipedia/commons/c/cd/Panda_Cub_from_Wolong,_Sichuan,_China.JPG";
var username = "tim";
var albumPicurl = "http://somesite.com/albumpic.jpg";
var userid = "3453454545";
var pageurl = "http://somesite.com/page2.html";
var time = "34534545435";
var text = "lifeiscool";
var fullname = "smith";
var likeimage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTyTZ5jtJ3VxrorGg0ywxXfEstaZWce2he-_6LSgFwsnch6xYUm";
$(".content").append("<div id='grid-cell' style='padding:5px'><a style='text-decoration:none' href='./dl.php?name=brian&imageurl=" + imageurl + "'><img class='photo-grid' src='" + imageurl + "' width=200 height=200 title='" + username + "' /></a><div id='like" + pageurl + "' style='float: right; padding: 5px 2px 2px;'> <img class='liker' onclick=postLike(" + imageurl + "," + username + "," + albumPicurl + "," + userid + "," + pageurl + "," + time + "," + text + ") src='" + likeimage + "' border='0'></div><div class='moreInfo2'><a style='color:#000;text-decoration:none' href='/" + username + "' target='_blank'>" + userid + "(" + fullname + ")</a></div></div>");
<div class="content"></div>