如何在onclick中访问test2()函数,如plain函数中所示,包装在圆括号中以指示运行时将函数返回到父范围,一旦返回函数为使用第4行执行,也许阅读这些步骤将有所帮助。jquery嵌套函数访问
<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。 – Jai