zoukankan      html  css  js  c++  java
  • paip.JS的调试DOM元素的属性与事件绑定


    paip.JS的调试--DOM元素的属性与事件绑定


    一段JQUERY1.7.2 的代码不能运行。。MS没起作用。

    $('.frame120_240_select ul a').click(function(){
        //  alert();
         $('#selectType').val($(this).html());
        // setLinkid($(this).html());
      });
      $('.frame120_240 .frame120_240_select').hover(function(){
       alert();
         $(this).addClass('frame120_240_select_hover');
      },function(){
         $(this).removeClass('frame120_240_select_hover');
      });


    放在IE9下,打开JS调试。报告找不到CLICK属性。
    或者用F12工具 ,启动JS调试,不用设断点。运行页面。精确停止定位到错误点。。

    确实是引用的JQEURY的。只能是JQUERY的$冲突定义了一定是。。因为页面引用了好多JS,一定是覆盖了$方法,不好排查,没办法,只好用原生JS进行事件设置了。

    先查找标签的事件属性。。百度DHTML,得到结果。。http://www.hbcms.com/main/dhtml/objects/a.html。。上面定义了A标签的属性。
    我需要的是a.innerText..

    然后要给DIV的MOUSEOVER和MOUSEOUT设置属性。可查找其DIV的属性。。最后结果是这样。

     var div=document.getElementById("frame120_240_selectDiv");
     div.οnmοuseοver=function(){
       
           this.className="frame120_240_select frame120_240_select_hover";
     };

     div.οnmοuseοut=function(){
           this.className="frame120_240_select";
    };

    然后IE9  F12,打上断点。运行在DIV这里,查看其onmouseover属性。可看到加载的事件,未加载的时候为NULL

  • 相关阅读:
    蓝桥杯入门训练
    <泛> STL
    传递 hdu 5961 拓扑排序有无环~
    Alice and Bob hdu 4268
    Bipartite Graph hdu 5313 bitset 并查集 二分图
    Bomb HDU 3555 dp状态转移
    不要62 hdu 2089 dfs记忆化搜索
    Leaving Auction CF 749D
    Moo University
    算法(三)
  • 原文地址:https://www.cnblogs.com/attilax/p/15199764.html
Copyright © 2011-2022 走看看