• JS使用传统的方法访问DOM对象


    <!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>
        <title></title>
        <style type="text/css"> 
        .divFrame
        {
           260px; border:solid 1px #666; font-size:10pt;
            }
        .divTitle
        {
            background-color:#eee; padding:5px;
            }
         .divContent
         {
             padding:8px; font-size:9pt;
             }
         .divTip
         {
             244px; border:solid 1px #666; padding:8px; font-size:9pt; margin-top:5px; display:none;
             }
        .txtCss
        {
            border:solid 1px #ccc;
            }
         .divBtn
         {
            padding-top:5px;
             }
         .divBtn.btnCss
         {
             border:solid 1px #535353; 60px;
             }
        </style>
        <script type="text/javascript">
            function btnClick() {
                //获取文本框的值
                var oTxtValue = document.getElementById('Text1').value;
                //获取单选框按钮值
                var oRdoValue = (Radio1.checked) ? "男" : "女";
                //获取复选框按钮值
                var oChkValue = (Checkbox1.checked) ? "已婚" : "未婚";
                //显示提示文本元素
                document.getElementById('divTip').style.display = "block";
                //设置文本元素内容
                document.getElementById('divTip').innerHTML = oTxtValue + '</br>' + oRdoValue + '</br>' + oChkValue;
            }
        </script>
    </head>
    <body>
    <div class="divFrame">
    <div class="divContent">
    姓名:<input id="Text1" type="text" class="txtCss" /><br />
    性别:<input type="radio" id="Radio1" name="rdoSex" value="男" />男
    <input id="Radio2" name="rdoSex" type="radio" value="女" />女<br />
    婚否:<input id="Checkbox1" type="checkbox" />
    <div class="divBtn"><input id="Button1" type="button" value="提交" class="btnCss"  onclick="btnClick();" /></div>
    </div>
    </div>
    <div id="divTip" class="divTip"></div>
    </body>
    </html>

  • 相关阅读:
    关于<?php exit;?>"的绕过问题
    机器学习--DIY笔记与感悟--②决策树(1)
    机器学习--DIY笔记与感悟--①K-临近算法(2)
    js 一些基础的理解
    js switch判断 三目运算 while 及 属性操作
    数据类型 数据类型转换 运算符
    数组的一些常用方法分析 介绍
    js常用的字符串方法分析
    js 的作用域 域解析 分析
    js 函数 作用域 全局作用域 局部作用域 闭包
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3024365.html
Copyright © 2020-2023  润新知