1.js事件阻止冒泡的应用

  1)问题描述:

    单机除了这两个元素,触发事件,JavaScript实现的功能

    可用阻止事件冒泡

  2)解决方法:  

    $('body').click(function(e){
        $('#searchTree').css("display","none");
        $('#searchText').css("display","none");
        $('#customerOwn').removeClass('highLight');
        $('#equipIdOrName').removeClass('highLight');
    })

//增加的2个条件单击事件
//设备号或名字
$('#equipIdOrName').click(function(e){
e.stopPropagation();//阻止这个事件向上冒泡
$('#searchTree').css("display","none");
$('#searchText').css("display","inline-block").attr("placeholder","设备号/设备名称");
$(this).addClass('highLight');
$('#customerOwn').removeClass('highLight');
});
//所属客户
$('#customerOwn').click(function(e){
e.stopPropagation();
$('#searchText').css("display","none");
$('#searchTree').css("display","inline-block");
$(this).addClass('highLight');
$('#equipIdOrName').removeClass('highLight');
});

 

 

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2022-02-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-11-18
  • 2022-02-20
相关资源
相似解决方案