火狐下button标签子元素无法点击

button下元素点击事件:在chrome和safari下每个a标签可以点击,在火狐下a标签无法点击

    <button>
        <a href="javascript:;" id="click1">adsf</a>
        <a href="javascript:;" id="click2">1231</a>
    </button>
    <script>

        /* 主要注意:
             button下元素点击事件: 
             在chrome和safari下每个a标签可以点击,
             在火狐下a标签无法点击
        */ 
        click1.onclick = function(e){
            console.log(e);
            e.stopPropagation();
            e.preventDefault();
            alert('adsf')
        }
        click2.onclick = function(e){
            e.stopPropagation();
            e.preventDefault();
            alert('1231')
        }
    </script>

 

posted on 2018-03-05 16:40  baoyadong  阅读(334)  评论(0编辑  收藏  举报

导航