【发布时间】:2015-09-24 11:19:38
【问题描述】:
如何在 onclick 中访问 test2() 外部函数,如普通函数所示,用括号括起来告诉运行时将函数返回到父作用域,一旦返回,函数将使用第 4 行执行,也许阅读这些步骤会有所帮助。
<p onclick='test().test2()'> some text </p>;
<script>
//the below declaration will not change
var jQuery = 'Hi';
(function ($) {
function test(){
function test2(){
alert('text')
}
alert($)
}
console.log($);
test().test2()
})(jQuery)
</script>
【问题讨论】:
-
一个简单的建议,可以在文档中查找 javascript 基础知识,尤其是 javascript 中的 OOP。
标签: javascript jquery object