Answers for "force click btn using jquery"

0

force click btn using jquery

example:

<button id='testButton'>Test</button>

<script>
$(function(){
   $('#testButton').on('click' , function(){
        alert("I've been clicked!");
   });

   //now on another event, in this case window resize, you could trigger
   //the behaviour of clicking the testButton?

  $( window ).resize(function() {
        $('#testButton').trigger( "click" );
  });

});

</script>
Posted by: Guest on January-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language