![](/img/trans.png)
[英]Javascript Prototype function and SVG setAttribute(onclick)
[英]pass a parameter in setAttribute "onclick" function argument in javascript
在這種情況下,您最好使用事件偵聽器,而不是嘗試使用 setAttribute 操作 onclick:
close.addEventListener("click", function(){
//do what you need here: call another function, do some math, etc...
checker('id'); //???
});
您可以使用:
close.onclick = function(){
checker('id'); // <-- are you sure you want to pass static string here?
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.