function changeColor(){
var obj1=document.getElementById("txt");
obj1.style.color="red";
obj1.style.backgroundColor="#ccc";
}//定义"改变颜色"的函数
function changeHeight(){
var obj2=document.getElementById("txt");
obj2.style.width="300px"
obj2.style.height="300px"
}
//定义"改变宽高"的函数
var obj1=document.getElementById("txt");
obj1.style.color="red";
obj1.style.backgroundColor="#ccc";
}//定义"改变颜色"的函数
function changeHeight(){
var obj2=document.getElementById("txt");
obj2.style.width="300px"
obj2.style.height="300px"
}
//定义"改变宽高"的函数
已采纳回答 / 塑造平凡3381862
function cancle(){var myfive=confirm("确定恢复原始值吗?");if ( myfive==true){document.getElementById("txt").style.cssText="";}}
2016-08-18
function openWindow(){
var mywin=confirm("确定打开默认网址:http://www.imooc.com/");
if(mywin==true)
{
window.open('http://www.imooc.com/','_blank','height=500,wight=400,menubar=no,toolbar=no')
} // 新窗口打开时弹出确认框,是否打开
else{
document.write("你取消打开默认网址")}
}
var mywin=confirm("确定打开默认网址:http://www.imooc.com/");
if(mywin==true)
{
window.open('http://www.imooc.com/','_blank','height=500,wight=400,menubar=no,toolbar=no')
} // 新窗口打开时弹出确认框,是否打开
else{
document.write("你取消打开默认网址")}
}
function rec(){
var score;
score = prompt("美女,可以悄悄告诉我你的身高吗:");
if(score>=165)
{
document.write("女神,嫁给我吧");
}
else if(score>=160)
{
document.write("妹子,约吗");
}
else if(score>=155)
{
document.write("小妹妹,叔叔带你去看金鱼");
}
else
{
document.write("额,我带你去找父母吧");
}
}
var score;
score = prompt("美女,可以悄悄告诉我你的身高吗:");
if(score>=165)
{
document.write("女神,嫁给我吧");
}
else if(score>=160)
{
document.write("妹子,约吗");
}
else if(score>=155)
{
document.write("小妹妹,叔叔带你去看金鱼");
}
else
{
document.write("额,我带你去找父母吧");
}
}
2016-08-18
已采纳回答 / vaneX
使用F12调试,情况如下:1. 当你使用了 :<...code...>id = "txt"的实际样式为:<...code...>2. 当你使用了:<...code...>id = "txt"的实际样式为:<...code...>由于 one 和 two 一样,你说样式会改变吗?建议使用:<...code...>这样才真正去掉了通过 mychar.style 添加的样式。
2016-08-18
<script type="text/javascript">
function rec(){
var mymessage= confirm("你喜欢我吗?") ;
if(mymessage==true)
{
document.write("你果然喜欢我!");
}
else
{
document.write("你敢不喜欢我试试!");
}
}
</script>
function rec(){
var mymessage= confirm("你喜欢我吗?") ;
if(mymessage==true)
{
document.write("你果然喜欢我!");
}
else
{
document.write("你敢不喜欢我试试!");
}
}
</script>
2016-08-18