简体   繁体   中英

Call onclick jQuery function once

How can I execute this function only one time? I tried bind or unbind but it doesn't work

<uib-tab-heading onclick="myFunction()"><i class="fa fa-keyboard-o"></i> Typing Test </uib-tab-heading>
function myFunction() {
    alert("hit");   
}

Try this below :

Use this flag in your $document.ready scope (global scope)

var flag = false

if(!flag){

    function myFunction() {
        flag = true;
        alert("hit");   
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM