自定义函数里面如何用THIS关键字?

不用THIS,用这个模拟。
比如:

1<a href="http://www.csdn.net" onclick="usr()">Click</a>
1<script>   
2function usr()   
3{alert(event.srcElement.href);}   
4</script>

如果不是对A调用自定义函数,就可以用直接用THIS.比如:

1<p href="http://www.csdn.net" onclick="usr()">Click
2<script>   
3function usr()   
4{alert(this.href);}   
5</script></p>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus