类似于这样单独拿出来的闭包函数
function init() {
var a= "abc";
function abcFunction() {
alert(abc);
}
abcFunction();
}
init();
如果套在HTML里面标签里面是个什么情况
name="" id="" onsubmit="abcd.xxx.xxxx=this.xxxxx.class==xxxxx; myFunction(e,n)">
能不能把onsbmit的样式放进myFunction里面,
说法很抽象见谅, 概括来说在html标签里可不可以有函数套函数的情况,谢谢
建议不要将js代码直接嵌入到dom中,不好管理。如果要使用到dom对象,事件中的this对象就是当前的dom,传入到函数中即可
onsubmit 实际要的是一个回调函数,你这种写法肯定不支持
不知道你说的是否是加defer属性去嵌套调用
<script type= "text/javascript ">
function hello(){
alert( "hello,world! ");
}
function testih(){
var s = "test! ";
s += " <script language= 'javascript ' type= 'text/javascript ' defer> ";
s += "hello(); ";
s += " < "+ "/script> ";
document.getElementById( "t ").innerHTML = s;
}
</script>
<div id= "t "> </div>
<input type= "button " value= "test " onclick= "testih(); ">
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!