<html><head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript"> var i=1; window.onload = function() { node_name = document.body.firstChild; node_name.setAttribute("src","images/sh_hero_1.jpg"); node_name.setAttribute("onclick","c(this)"); } function c(q) { i++; q.setAttribute("src","images/sh_hero_"+i+".jpg"); } </script></head><body><img/></body></html>node_name.setAttribute("onclick","c(this)");中的this工作原理是什么?為什么能把node_name這個局部變量傳出去?新人小白求輕拍。
js函數中this的傳值的問題
DIEA
2018-09-04 09:10:06