user1381806
user1381806

Reputation: 529

Jquery - If DIV is shown //do something

I have a slot machine plugin here that rotates UL's and shows one of them randomly.

I would like the shown UL to set a value.

Something like this:

if ($("#1").is(":visible") == true) {
 dial.setValue(8);
};

Hope you can help.

Thanks.

Upvotes: 1

Views: 713

Answers (2)

mplungjan
mplungjan

Reputation: 177684

onEnd :function() { ... }, seems to be where you need your function

// Function: run on spin end. It is passed (finalNumbers:Array).
// finalNumbers gives the index of the li each slot stopped on in order.

Not quite sure why I only get one item, but here is code that works

DEMO

onEnd: function(finalNumbers) { 
         if (finalNumbers[0]==1) dial.setValue(8); // found 1st li
       }

Upvotes: 1

Nealv
Nealv

Reputation: 6884

Add a function on the onEnd parameter, the variable passed in the function is the final value in the spinner

    // --------------------------------------------------------------------- //
    // DEFAULT OPTIONS
    // --------------------------------------------------------------------- //

    $.jSlots.defaultOptions = {
        number : 1,          // Number: number of slots
        spinner : '',        // CSS Selector: element to bind the start event to
        spinEvent : 'click', // String: event to start slots on this event
        onStart : $.noop,    // Function: runs on spin start,
        onEnd :   function handleEnd($finalNumber){alert(finalNumber);},      // Function: run on spin end. It is passed (finalNumbers:Array). finalNumbers gives the index of the li each slot stopped on in order.
        onWin : $.noop,      // Function: run on winning number. It is passed (winCount:Number, winners:Array)
        easing : 'swing',    // String: easing type for final spin
        time : 7000,         // Number: total time of spin animation
        loops : 6            // Number: times it will spin during the animation
    };

Upvotes: 0

Related Questions