zoukankan      html  css  js  c++  java
  • 点击挂上事件,点击移除事件+进度条例题

    无标题文档

    点击挂上事件 点击移除事件

    <!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>无标题文档</title>

    <style type="text/css">
    *{ margin:0px auto; padding:0px; font-family:微软雅黑; font-size:14px;}

    </style>

    </head>
    <body>
    <div id="dd" style="200px; height:200px; background-color:#669">
    这是一个层
    </div>
    <span onclick="add1()">点击挂上事件</span>
    <span onclick="remove1()">点击移除事件</span>

    </body>
    <script type="text/javascript">
    function showdd()
    {
    alert("被点中了");
    }
    function add1()
    {
    var d = document.getElementById("dd");
    d.onclick = function (){showdd()}; //匿名函数
    }
    function remove1()
    {
    var d = document.getElementById("dd");
    d.onclick = function (){}; //空匿名函数
    }

    </script>
    </html>
    2.进度条

    <!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>无标题文档</title>
    <style type="text/css">
    *{ margin:0px auto; padding:0px}
    #wai{ 200px; height:10px; border:1px solid #60F;}
    #nei{ 0px; height:10px; background-color:#F33; float:left}
    </style>
    </head>

    <body>

    <div style="600px; height:300px; margin-top:30px">


    <div id="wai">
    <div id="nei">

    </div>
    </div>

    <input type="button" value="开始" onclick="Start()" />
    </div>

    </body>
    <script type="text/javascript">

    function Start()
    {
    Bian();
    }

    var bfb = 0;
    function Bian()
    {
    //将百分比变化
    bfb= bfb+1;

    //改变宽度
    document.getElementById("nei").style.width = bfb+"%";

    //判断
    if(bfb<100)
    {
    window.setTimeout("Bian()",50);
    }

    }

    </script>
    </html>

  • 相关阅读:
    深入学习JavaScript: apply 方法
    javascript中的sort()方法
    vertical-align的用法
    js中window.onload与jquery$(document).ready()的区别
    js两种定义函数的方式(调用声明先后的区别)
    jquery插件写法的模板
    对兼容ie浏览器所遇到的问题及总结
    ie 6下使用jquery的mouseover会出现抖动现象的解决方法
    清除ie8下input file 文件域的值的方法
    fabric简介(二)
  • 原文地址:https://www.cnblogs.com/zxl89/p/5912322.html
Copyright © 2011-2022 走看看