alt-rock alt-rock - 1 year ago 69
Javascript Question

call jquery function on the active class with event handler

I am trying to call a function to add class

to a link on the event when the carousel slide has the class
. The active class iterates over each item, toggling on and off. However the event handler i chose
is not triggering the function to happen. How can i add the class when the item is active?

<div class="carousel">
<div class="item"><a id="link1"></a></div>
<div class="item"><a id="link2"></a></div>
<div class="item active"><a id="link3"></a></div>

// if slide active, add class hover to the link
var test = jQuery('.hover');
function linkHover(){
if(jQuery('').length != 0){

jQuery(test).on( 'trigger', linkHover );

Answer Source

I think your making this more difficult than it needs to be. There should be a function that is called to switch the slide on the carousel. Inside that function just add:

$('.item').each(function() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download