码迷,mamicode.com
首页 > 其他好文 > 详细

document对象

时间:2015-05-16 07:53:37      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>document对象</title>
</head>

<body>

<div id="me">
    <b>试试吧</b>
</div>
<script>
/*var a=document.getElementById("me");
a.innerHTML="<font color=red >hello world</font>";
alert(a.innerText);*/
</script>


<form name="" id="f1">
<input type="text" id="f1" value="你好">
</form>
<script>
/*
var t=document.getElementById("t1")
alert(t.value);*/
</script>

<font id="f1" >
获取属性的值,并更改属性.
</font> 

<script>
/*
var x=document.getElementById("f1");
x.setAttribute("color","red");//设置一个属性,添加或更改都可以.
*/
</script>

<form>
中华民国成立于哪一年?
<input type="text" daan="1912" value="" id="t1" name="t1"/>
<input type="button" onclick="check()" id="t2" name="t2" value="检查答案是否正确"/>
</form>

<script>
function check()
{
    var a=document.getElementById("t1");
    var a1=a.value;
    a.setAttribute("daan","1912年"); //更改某一属性的值
    var a2=a.getAttribute("daan");//获取某一属性的值
    if(a1==a2)
    {
        alert("恭喜你答对了.")
    }
    else
    {
        alert("fool");
    }    
}
</script>


<form>
<input type="submit" id="b1" name="b1" value="同意(9)" disabled="disabled"/>
</form>
<script>
var n=10;
var a=document.getElementById("b1");

function bian()
{
    n--;
    if(n==0)
    {
        a.removeAttribute("disabled");
        a.value="同意";
        }
    else
    {
        a.value="同意("+n+")";
        window.setTimeout("bian()",1000)
        }
}
window.setTimeout("bian()",1000);

</script>

</body>
</html>

 

document对象

标签:

原文地址:http://www.cnblogs.com/lk-kk/p/4507193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!