This是我的代码:为什么我不能从2个函数内部调用该函数?
inserisciMarker();
function scorriAllaLista(param) {
alert(param);
}
function inserisciMarker() {
markerClick = function() {
$('#example').attr("onclick", "scorriAllaLista('hello'); return false;");
};
markerClick();
}
点击链接,Uncaught ReferenceError: scorriAllaLista is not defined
为什么?我该如何解决它?
最有可能它没有全球定义。 'window.scorriAllaLista = scorriAllaLista'为什么你用javascript设置onclick属性而不是绑定一个事件? – 2013-03-20 14:11:58
你不应该使用'attr()'来添加事件处理程序! – epascarello 2013-03-20 14:12:11
@both:我不能,对于这个未解决的问题:http://stackoverflow.com/questions/13033506/why-i-cant-attach-an-dynamic-event-handler-to-this-element – markzzz 2013-03-20 14:13:52