我正在 ajax 我的内容,但不明白为什么我无法将变量传递给我的函数事件:
..每个循环内的某个地方
var file = 'something';
html+='<li><a href="" onclick="return false;" onmouseup="preview('+file+');" style="background: url('link') no-repeat;"></a></li>';
}
function preview(file)
...
alert(file);
最佳答案
添加变量后引用的文本是什么样的:
'<li><a href="" onclick="return false;" onmouseup="preview(something);" style="background: url('link') no-repeat;"></a></li>'
连接字符串中的某些内容未用引号引起来。
关于javascript - 如何通过onmouseup发送属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2957189/