For example, there is a handler
$("#btn1").click(function(){ $('body').append("<div class='test'></div>"); }) How to allow execution only 1 time?
"); }) How to allow e...">
For example, there is a handler
$("#btn1").click(function(){ $('body').append("<div class='test'></div>"); }) How to allow execution only 1 time?
Use the .one() method to do this:
$("#btn1").one('click', function(){ $('body').append("<div class='test'>Something</div>"); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type='button' id='btn1' value='Click me!' /> removeEventListener method and starts the function itself. - user207618Source: https://ru.stackoverflow.com/questions/560721/
All Articles