Monday, 15 July 2013

jquery - Why can't i call this function with my variables? -



jquery - Why can't i call this function with my variables? -

i'm trying phone call function 2 variables:

$('#sub-nav li a').on('click', function(event) { event.preventdefault(event); // slider utilize var $sliderno = $(this).attr('data-slider'); var $slider = "#flexslider" + $sliderno; // slide show var $slide = $(this).attr('data-slide'); // lets click on link slider 1, , link slide 1: alert($slide); // alert right data-slide number alert($slider); // alert: '#flexslider1' $("#flexslider1").flexslider(1); //this run! $($slider).flexslider($slide); // won't run! - why? });

why can't phone call $($slider).flexslider($slide); $variables?

try this

$('#sub-nav li a').on('click', function(event) { event.preventdefault(); // slider utilize var $sliderno = $(this).data('slider'); var $slider = "#flexslider" + $sliderno; // slide show var $slide = $(this).data('slide'); // lets click on link slider 1, , link slide 1: alert($slide); // alert right data-slide number alert($slider); // alert: '#flexslider1' $("#flexslider1").flexslider(1); //this run! $($slider).flexslider($slide); // won't run! - why? });

jquery

No comments:

Post a Comment