照理说函数建立后是不能自动执行的,需要调用。那么这里的函数为什么没有被调用就生效了?
function add(){
var p1 = document.getElementById("p1");
p1.className="one";
}
function modify(){
var p2 = document.getElementById("p2");
p2.className="two";
}
function add(){
var p1 = document.getElementById("p1");
p1.className="one";
}
function modify(){
var p2 = document.getElementById("p2");
p2.className="two";
}
2016-04-18
这样不能过我不服
var add2= contxt() //定义函数
{
alert("哈哈,调用函数了!");
}
var add2= contxt() //定义函数
{
alert("哈哈,调用函数了!");
}
2016-04-17
已采纳回答 / one丿pieceLJ
document.write("hello"); document.getElementById("p1").style.color="blue";
2016-04-17
最新回答 / 慕粉3166661
function openWindow() { var open = confirm("窗口是否打開?"); var url = "http://www.imooc.com/"; if(open == true){ confirm("打開網址"+ url); window.open("url","_blank","width=400, height=500, menubar=no, toolbar=no") ...
2016-04-17
function openWindow(){
var mymessage=confirm("确认要打开新窗口?");
var myurl="http://www.imooc.com/";
if(mymessage==true){
prompt("您要打开的网址为:","http://www.imooc.com/");
window.open(myurl,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
}
var mymessage=confirm("确认要打开新窗口?");
var myurl="http://www.imooc.com/";
if(mymessage==true){
prompt("您要打开的网址为:","http://www.imooc.com/");
window.open(myurl,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
}
//定义"取消设置"的函数
function Reset(){
var a=confirm("是否要取消设置?");
if (a==true)
{
a=document.getElementById("txt");
// a.style="#txt";
a.removeAttribute("style");
}
}
function Reset(){
var a=confirm("是否要取消设置?");
if (a==true)
{
a=document.getElementById("txt");
// a.style="#txt";
a.removeAttribute("style");
}
}
最赞回答 / 幸福的小草
if(score=null){//这里判断条件错了,应该是scroe==null; document.write("OK"); }score=null;是给score赋了一个null的值,无论输入是什么,代码执行到上面的语句后,都把score的值重新赋值为null了,所以 都会执行 document.write(score+"要努力了!")
2016-04-17