Trigger layer event with JavaScript
⚠️ This article was created for developers!
To be able to follow the steps, you're required to have coding knowledge. If you're not a developer and can't achieve what you're looking for, consider hiring a developer.
Make sure to carefully follow the tutorial and write correct code. We're unable to provide help with custom coding, or the possible issues that are happening because of them.
You can trigger a custom event with JavaScript code like this:
n2ss.trigger(document.querySelector('.n2-ss-slide-active'), 'eventname');
For example, trigger the "switch" event on slide switching at slider #10:
_N2.r('#n2-ss-10', function(){ var slider = _N2['#n2-ss-10']; slider.sliderElement.addEventListener('mainAnimationComplete', function(e) { n2ss.trigger(document.querySelector('#n2-ss-10 .n2-ss-slide-active'), 'switch'); }); });
n2ss.trigger(document.querySelector('.n2-ss-static-slide'), 'switch');