<script type="text/javascript">
function rec(){
var mymessage=confirm("你喜欢我吗?");
if(mymessage==true)
{document.write("我也喜欢你呀!");}
else
{ document.write("我这么可爱你为什么不喜欢我QwQ"); }
}
</script>
</head>
<body>
<input name="button" type="button" onClick="ren()" value="点我点我"/>
</body>
function rec(){
var mymessage=confirm("你喜欢我吗?");
if(mymessage==true)
{document.write("我也喜欢你呀!");}
else
{ document.write("我这么可爱你为什么不喜欢我QwQ"); }
}
</script>
</head>
<body>
<input name="button" type="button" onClick="ren()" value="点我点我"/>
</body>
2018-09-29
var mychar= document.getElementById("con");
和
var mychar= document.getElementById('con');
只是引号不一样,js应该都能识别,慕课上只能识别双引号
和
var mychar= document.getElementById('con');
只是引号不一样,js应该都能识别,慕课上只能识别双引号
2018-09-28
function add(){
var p1 = document.getElementById("p1");
p1.className:one;
}
function modify(){
var p2 = document.getElementById("p2");
p2.className=two;
}
object.className=className;就会验证通过了,不用加双引号
var p1 = document.getElementById("p1");
p1.className:one;
}
function modify(){
var p2 = document.getElementById("p2");
p2.className=two;
}
object.className=className;就会验证通过了,不用加双引号
2018-09-26
写了一个生成随机颜色的 拿去玩吧
//随机生成颜色
function randomColor(){
var str="#";
var a=["1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f"];
for(var i=1;i<4;i++){
str+=a[parseInt(Math.random()*16)];
}
return str;
}
//随机生成颜色
function randomColor(){
var str="#";
var a=["1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f"];
for(var i=1;i<4;i++){
str+=a[parseInt(Math.random()*16)];
}
return str;
}
//和/* */是JavaScript的注释符号, <html><head><body>的注释应该是<!-- --> 注释快捷键:单行ctrl+/ 多行ctrl+shift+/
2018-09-13