改变 <p> 元素的样式,将颜色改为红色,字号改为20,背景颜色改为蓝:
<p id="pcon">Hello World!</p>
<script>
var mychar = document.getElementById("pcon");
mychar.style.color="red";
mychar.style.fontSize="20";
mychar.style.backgroundColor ="blue";
</script>
<p id="pcon">Hello World!</p>
<script>
var mychar = document.getElementById("pcon");
mychar.style.color="red";
mychar.style.fontSize="20";
mychar.style.backgroundColor ="blue";
</script>
2015-11-18
<script type="text/javascript">
var mychar=document.getElementById("con") ;
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello world!";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
var mychar=document.getElementById("con") ;
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello world!";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
2015-11-18
<html>
<head>
<title>***</title>
<script type="text/javascript">
var score=80;
if(score>=60)
{
document.write("");
}
else{
document.write("");
}
<script>
</head>
<body>
</body>
</html>
<head>
<title>***</title>
<script type="text/javascript">
var score=80;
if(score>=60)
{
document.write("");
}
else{
document.write("");
}
<script>
</head>
<body>
</body>
</html>
2015-11-17
//定义"取消设置"的函数
function cancel(){
var btn5 = document.getElementsByTagName('input')[4];
var text = document.getElementById('txt');
btn5.onclick = function(){
if(confirm){
text.removeAttribute('style');
}
}
}
cancel();
function cancel(){
var btn5 = document.getElementsByTagName('input')[4];
var text = document.getElementById('txt');
btn5.onclick = function(){
if(confirm){
text.removeAttribute('style');
}
}
}
cancel();
function show(){
var btn4 = document.getElementsByTagName('input')[3];
var text = document.getElementById('txt');
btn4.onclick = function(){
text.style.display = 'block';
}
}
show();
var btn4 = document.getElementsByTagName('input')[3];
var text = document.getElementById('txt');
btn4.onclick = function(){
text.style.display = 'block';
}
}
show();