我有被设定为一个变量如何通过一个变量/和在JavaScript的onclick功能
var imagepath = "../Resources/Images/teamLogo1.png";
现在的图像我要通过这个作为一个参数的点击一些路径参数的的onclick功能
请检查fiddle here
我追加的形象和我需要写的onclick功能有 编辑: 包括完整的代码
$(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);
};
请在此复制相关代码;现在人们需要看到小提琴完全了解你所问的。 –
好的代码中添加了!谢谢 –