jQuery trigger()

ljnce

Luca

Posted on January 14, 2021

jQuery trigger()

Hi dev!πŸ™‹β€β™‚οΈ

During my work i used an event looks very interessant: is a trigger() event.

The trigger() method triggers the specified event more times:
πŸ§‘β€πŸ’»

<button type="button" class="click"> CLICK </button>

<div class="container">
</div>
Enter fullscreen mode Exit fullscreen mode
$('.button').click(function(){
    $(document).trigger('nameOfMyTriggerEvent')
})

$(document).on('nameOfMyTriggerEvent', function(){
    $('.container').hide();
})

Enter fullscreen mode Exit fullscreen mode

It's easy and very usefull if you need to trigger an event more times.

Hope it helpfully!
✌️

πŸ’– πŸ’ͺ πŸ™… 🚩
ljnce
Luca

Posted on January 14, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related