点击时如何设置按钮显示图层(div)[暂停]

loading...


-1

点击时如何设置按钮标签显示图层(div)?我只是尝试使用锚标签运行良好 . 但按钮标签不起作用

请帮忙 .

$(function($) {
  $("a[onclick^='layerpop.showLayerPop'], button[onclick^='layerpop.showLayerPop']").click(function() {
    $('.on').removeClass('on');
    $($(this).addClass('on').attr('href')).attr('tabindex', '0').show().focus();
  });
  $('.layer_close').click(function() {
    $(this).parent().hide();
    $('.on').focus();
  });
});
.popup {  display: none}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="#target1" onclick="layerpop.showLayerPop('target1');">Anchor 1</a> 
or 
<button onclick="layerpop.showLayerPop('target1');"> 111</button> 
<br><br> 
  
 
<a href="#target2" onclick="layerpop.showLayerPop('target2');">Anchor 2</a> 
or
<button onclick="layerpop.showLayerPop('target2');"> 22</button>





<div id="target1" class="popup">
  Layer Target 1 <button class="layer_close" type="button">Close</button>
</div>


<div id="target2" class="popup">
  Layer Target 2 <button class="layer_close" type="button">Close</button>
</div>

loading...

0回答

No Data

评论

暂时没有评论!