onclick and ontouchstart simultaneously

后端 未结 6 1919
花落未央
花落未央 2021-02-08 21:23

I have an ontouchstart event triggered on my mobile view, its linked to this:

function mobileLinksShow() {
    document.querySelector(\'.mobile-head         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-08 21:54

    You can write it this way:

    var called = false;
    function mobileLinksShow() {
        if(!called)
            document.querySelector('.mobile-head-bar-links').classList.toggle('mobile-head-bar-links-transition');
            called = true;
        }
    }
    

    But: If you use this code, the function can only be called once, even if you click the span twice.

提交回复
热议问题