我的模块中有一个JavaScript程序;说test1.js
。它有IF..ELSEIF
声明。我的挑战是我想.js
根据IF-ELSE
语句中的条件调用不同的程序。
TEST1.js
看起来像 -
-----
if(cond1) {
//want to call test2.js here
}
else if(cond2) {
//want to call test3.js here
}
如何在javascript中执行此操作?
if(cond1)
{
//want to call test2.js here
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "test2.js";
document.body.appendChild(js);
}
else if(cond2)
{
//want to call test3.js here
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "test3.js";
document.body.appendChild(js);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句