//定义"改变颜色"的函数
function changcolor(){
var a=document.getElementById("txt");
a.style.color="red";
}
//定义"改变宽高"的函数
function changwidth(){
var a=document.getElementById("txt");
a.style.height="300px";
a.style.width="450px";
}
function changcolor(){
var a=document.getElementById("txt");
a.style.color="red";
}
//定义"改变宽高"的函数
function changwidth(){
var a=document.getElementById("txt");
a.style.height="300px";
a.style.width="450px";
}
最赞回答 / 逗木木
<script type="txet/javascript">用来告诉浏览器这是用Javascript编写的程序,并且标示该网页的类型为文本类型。你拼错了javascript,改正之后试一下看看
2016-08-19
//定义"取消设置"的函数
btn[4].onclick=function(){
var set;
set=confirm("是否取消设置?");
if(set==true){
var mycan=document.getElementById("txt").style.cssText="";
}
};
</script>
btn[4].onclick=function(){
var set;
set=confirm("是否取消设置?");
if(set==true){
var mycan=document.getElementById("txt").style.cssText="";
}
};
</script>
//定义"显示内容"的函数
btn[3].onclick=function(){
txt.style.display="block";
};
btn[3].onclick=function(){
txt.style.display="block";
};
//定义"改变宽高"的函数
btn[1].onclick=function(){
txt.style.width="400px";
txt.style.height="600px";
};
btn[1].onclick=function(){
txt.style.width="400px";
txt.style.height="600px";
};
<script type="text/javascript">
var txt=document.getElementById("txt");
var btn=document.querySelectorAll("input");
//console.log(btn)
//定义"改变颜色"的函数
btn[0].onclick=function(){
txt.style.color="red";
txt.style.backgroundColor="blue";
};
var txt=document.getElementById("txt");
var btn=document.querySelectorAll("input");
//console.log(btn)
//定义"改变颜色"的函数
btn[0].onclick=function(){
txt.style.color="red";
txt.style.backgroundColor="blue";
};
<script type="text/javascript">
var mychar= document.getElementById("con");//获取的是p标
document.write("结果:"+mychar+"<br>"); //输出获取的P标签。
var mycontest= document.getElementById("con").innerHTML;//获取<p>的内容
document.write("<br>"+"结果内容:"+mycontest);
var mychar= document.getElementById("con");//获取的是p标
document.write("结果:"+mychar+"<br>"); //输出获取的P标签。
var mycontest= document.getElementById("con").innerHTML;//获取<p>的内容
document.write("<br>"+"结果内容:"+mycontest);
2016-08-19
function openWindow(){
var ifOpen=confirm("是否打开该网页?");
if(ifOpen==true){
window.open('http://www.imooc.com/','慕课网','width=400,height=500')
}
else{
ifOpen.close();
}
}
var ifOpen=confirm("是否打开该网页?");
if(ifOpen==true){
window.open('http://www.imooc.com/','慕课网','width=400,height=500')
}
else{
ifOpen.close();
}
}
<script type="text/javascript">
var mychar= document.getElementById("con1") ;
document.write("结果:"+mychar); //输出获取的P标签
输出Null
<script type="text/javascript">
var mychar= document.getElementById("con") ;
document.write("结果:"+mychar); //输出获取的P标签。
</script>
输出[object HTMLParagraphElement]
var mychar= document.getElementById("con1") ;
document.write("结果:"+mychar); //输出获取的P标签
输出Null
<script type="text/javascript">
var mychar= document.getElementById("con") ;
document.write("结果:"+mychar); //输出获取的P标签。
</script>
输出[object HTMLParagraphElement]
2016-08-19
<input type="button" value="改变颜色" onclick="changeColor();" >
<input type="button" value="改变宽高" onclick="changeWH();">
<input type="button" value="隐藏内容" onclick="changenone();">
<input type="button" value="显示内容" onclick="changeBlock();">
<input type="button" value="取消设置" onclick="change();">
<input type="button" value="改变宽高" onclick="changeWH();">
<input type="button" value="隐藏内容" onclick="changenone();">
<input type="button" value="显示内容" onclick="changeBlock();">
<input type="button" value="取消设置" onclick="change();">