zoukankan      html  css  js  c++  java
  • HTML DOM教程 19HTML DOM Button 对象

    HTML DOM教程 19-HTML DOM Button 对象

      1:Button 对象

      Button 对象代表一个按钮。

      在 HTML 文档中 <button> 标签每出现一次,Button 对象就会被创建。

      2:Button 对象的属性

    属性 描述 IE F O W3C
    accessKey 设置或返回访问某个按钮的快捷键。 6 1 9 Yes
    disabled 设置或返回是否禁用按钮。 6 1 9 Yes
    form 返回对包含按钮的表单的引用。 6 1 9 Yes
    id 设置或返回按钮的 id。 6 1 9 Yes
    name 设置或返回按钮的名称。 6 1 9 Yes
    tabIndex 设置或返回按钮的 Tab 键控制次序。 6 1 9 Yes
    type 返回按钮的表单类型。 6 1 9 Yes
    value 设置或返回显示在按钮上的文本。 6 1 9 Yes

      3:标准属性

    Property Description IE  F O W3C
    className Sets or returns the class attribute of an element 5 1 9 Yes
    dir Sets or returns the direction of text 5 1 9 Yes
    lang Sets or returns the language code for an element 5 1 9 Yes
    title Sets or returns an element's advisory title 5 1 9 Yes

       4:className 属性  

      本例展示了两种获得 <body> 元素的 class 属性的方法:

    <html>
    <body id="myid" class="mystyle">
    <script type="text/javascript">
    x=document.getElementsByTagName('body')[0];
    document.write("Body CSS class: " + x.className);
    document.write("<br />");
    document.write("An alternate way: ");
    document.write(document.getElementById('myid').className);
    </script>
    </body>
    </html>

    输出:

    Body CSS class: mystyle
    An alternate way: mystyle

    5:其他属性演示

      <html>

    <head>
    <script type="text/javascript">
    function alertId()
    {
    var txt="Id: " + document.getElementById("myButton").id

    txt=txt + ", type: " + document.getElementById("myButton").type

    txt=txt + ", type: " + document.getElementById("myButton").form
     

    alert(txt)
    document.getElementById("myButton").disabled=true
    }
    </script>
    </head>

    <body>
    <form>
    <button id="myButton" onClick="alertId()">请点击我!</button>
    </form>

    </body>

        </html>



  • 相关阅读:
    AppDomain以及如何改变web.config / App.config位置
    事实与谎言 软件工程
    REST WebServices学习
    项目沟通案例:最近项目开发中的扯皮问题
    用户界面设计的技巧与技术(By Scott W.Ambler)
    C#集合类(HashTable, Dictionary, ArrayList)与HashTable线程安全
    About
    Leading by Example
    Pair Programming vs. Code Reviews
    使用jqueryeasyui写的CRUD插件(2)
  • 原文地址:https://www.cnblogs.com/pricks/p/1448963.html
Copyright © 2011-2022 走看看