zoukankan      html  css  js  c++  java
  • jquery事件

    为按钮挂事件和移除事件

    <body>
    <input type="button" value="挂事件" id="gua" />
    <input type="button" value="测试事件" id="ceshi" />
    <input type="button" value="移除事件" id="yichu" />
    </body>
    <script type="text/javascript">
            //点击给测试事件添加
    $("#gua").click(function(){
        $("#ceshi").bind("click",function(){
        alert ("挂上了事件");
    });
    })
    
    //点击移除 移除刚刚给测试事件挂上的事件
    $("#yichu").click(){
        $("#ceshi").unbind("click");
    })
    </script>

    实现点击色块

    <!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>
    <script src="jquery-1.11.2.min.js"></script>
    <style type="text/css">
    .aa{ 200px; height:200px; float:left; margin:5px; background-color:#3F6}
    </style>
    </head>
    
    <body>
    
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    <div class="aa">
    </div>
    
    <input type="button" value="测试" onclick="test()" />
    
    </body>
    <script type="text/javascript">
    $(".aa").click(function(){
        //将所有元素的背景色变成原来的颜色
          $(".aa").removeAttr("xz");
          $(".aa").css("background-color","#3f6");
        //找到点击了谁
          $(this).css("background-color","yellow");
            $("[xz='1']").css("background-color","red");
    })
  • 相关阅读:
    eclipse FilteredTree
    Windows API高精度计时 C#版
    循环中响应消息,避免循环时UI线程被阻塞
    Linux rpm 包制作 使用 rpmbuild
    利用Windows API实现精确计时
    C++显示选择文件夹对话框
    android AsyncTask
    [转]Android 动画学习笔记
    eclipse 中导入android 工程时出错:The method of type must override a superclass method 解决方式
    Android 自定义对话框
  • 原文地址:https://www.cnblogs.com/xiaoming-6/p/6267216.html
Copyright © 2011-2022 走看看