I have some path which is set to a variable
var imagepath = "../Resources/Images/teamLogo1.png";
Now on click of an image I have to pass this as a parameter in its onclick function
Please check the fiddle here
I am appending the image and i need to write onclick function there EDIT: Including the full code
$(document).ready(function(){
var imagepath = "../Resources/Images/teamLogo1.png";
$("#Testing").append('<img src="http://www.magerempowerment.com/v2/blog/wp-content/uploads/2012/07/doubt_dice.jpg" onClick="testfunction('+ imagepath + ')">');
});
function testfunction(imagepath){
alert(imagepath);
};