• Resolved alvior

    (@alvior)


    HI all,

    I am not sure what the problem is, let me try to describe it.
    there is a button call “calculate” in HTML file which mapped to below script.

    jQuery(document).ready(function( $ ){
    var button = $(“#button1”)  

    button.on(“click”, () => {
    alert(“1”);
    });

    });

    After all codes published, I click the button, the alert message show 4 times.
    Any idea?

    p.s. only the button of “calculate” function added

    Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter alvior

    (@alvior)

    I test by another way, it looks like function of “jQuery(document).ready(function( $ )” run 4 times.

    var i=0
    jQuery(document).ready(function( $ ){
    var button = $(“#button1”);

    button.on(“click”, () => {
    i++
    alert(i);
    });

    });

    Thread Starter alvior

    (@alvior)

    I found that if the “Linking type” select “External File”, “jQuery(document).ready(function( $ )” run 4 times.

    And, “Linking type” select “Internal” only run 1 time.

    But datepicker is not working under “Internal” type which function is belong to Jquery UI..

    • This reply was modified 5 years, 8 months ago by alvior.
    • This reply was modified 5 years, 8 months ago by alvior.
    Thread Starter alvior

    (@alvior)

    Problem disappear…
    I only updated same code..
    Function looks normal now, did not run many times.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘function run four times in jquery’ is closed to new replies.