猿问
JavaScript if函数4个条件怎么用?
比如:星期一、二运行A.JS;星期三、四运行B.JS;星期五、六运行C.js,星期日运行D.js
翻过高山走不出你
浏览 2566
回答 3
3回答
德玛西亚99
1234567891011var myd=new Date();var myweek=myd.getDay();if(myweek==1||myweek==2){ document.write("<script src=\"A.js\"></script>")}else if(myweek==3||myweek==4){ document.write("<script src=\"B.js\"></script>")}else if(myweek==5||myweek==6){ document.write("<script src=\"C.js\"></script>")}else if(myweek==0){ document.write("<script src=\"D.js\"></script>")}
0
0
0
郎朗坤
var week = new Date().getDay();if (week == 0) {document.write("<script src='D.js'><\/script>");} else if (week == 1 || 2) {document.write("<script src='A.js'><\/script>");} else if (week == 3 || 4) {document.write("<script src='B.js'><\/script>");} else if (week == 5 || 6) {document.write("<script src='C.js'><\/script>");}大致方向具体语法有待测试
0
0
0
慕勒3428872
var obj={};obj.Funtext=function(){};if(obj.Funtext){alert("true obj.Funtext;");}else{alert("false obj.Funtext");}obj.Funtext=function(){};if(obj.Funtext()){alert("true obj.Funtext();");}else{alert("false obj.Funtext()");}
0
0
0
随时随地看视频
慕课网APP
相关分类
Vue.js
我要回答