zoukankan      html  css  js  c++  java
  • js点击事件获取当前元素或父级元素

    1.通过设定标签,在js里写click事件

    html:

    <div style="margin-left: 77px; background-color: white; line-height: 30px; padding-left: 5px;">
         <a class="pro deleteBrand" title="适用季节" href="javascript:void(0);">适用季节
            <span class="icon-btn-x">x</span>
         </a>
         <a class="pro deleteBrand" title="适用季节" href="javascript:void(0);">适用季节
             <span class="icon-btn-x">x</span>
         </a>
         <a class="pro deleteBrand" title="适用季节" href="javascript:void(0);">适用季节
             <span class="icon-btn-x">x</span>
         </a>
         <a class="pro" id="btn-brand-search" title="适用季节" href="javascript:void(0);">更多∨</a>
      </div>

    js:

    deleteBrand : function () {
      $(".deleteBrand").click(function (aa) {
         $(this).css('display', 'none');
       //$(this).parent().css('display', 'none');
      });
    }

    2.在html页面写click事件

    html:

    <div style="margin-left: 77px; background-color: white; line-height: 30px; padding-left: 5px;">
       <a class="pro" data-url="nav"  title="适用季节" href="javascript:void(0);" onclick="new goodsUpperAndLower.init().deleteBrand(this);">适用季节
           <span class="icon-btn-x">x</span>
       </a>
       <a class="pro" data-url="nav"  title="适用季节" href="javascript:void(0);" onclick="new goodsUpperAndLower.init().deleteBrand(this);">适用季节
           <span class="icon-btn-x">x</span>
       </a>
       <a class="pro" data-url="nav"  title="适用季节" href="javascript:void(0);" onclick="new goodsUpperAndLower.init().deleteBrand(this);">适用季节
           <span class="icon-btn-x">x</span>
       </a>
       <a class="pro" id="btn-brand-search" title="适用季节" href="javascript:void(0);">更多∨</a>
     </div>

    js:

    deleteBrand : function (obj) {
       //$(obj).parent().css('display', 'none');
       $(obj).css('display', 'none');
    }
  • 相关阅读:
    浅涉OPC Client
    枚举目标机器已注册的OPC服务器
    C++ DCOM服务器和C#客户端互操作完全解释
    COMException:没有注册类别(REGDB_E_CLASSNOTREG)
    网络化广播主机ZABKZ/AXT8182
    OPC 技术文档之 IOPCBrowseServerAddressSpace 的使用
    SQL Server 2008 r2 服务无法启动
    Infinova V2040 系列 大型矩阵切换/控制系统
    COM中GUID和UUID、CLSID、IID
    django 视图与网址
  • 原文地址:https://www.cnblogs.com/jcjssl/p/9546370.html
Copyright © 2011-2022 走看看