javascript - Reference to a bxslider after it has been created -
is possible reference bxslider has been applied element, after has been created?
commonly, can reference when slider if first created.
var myslider; $(function(){ myslider = $('#slider').bxslider({ auto: true, controls: true }); });
however, if have multiple sliders on same page, , being reference class instead of id, nice able reference slider object, after fact.
for example
html:
<ul class="slider" id="my-specific-slider">...</ul> <ul class="slider" >...</ul> <ul class="slider" >...</ul>
js:
var myslider; $(function(){ $('.bxslider').bxslider({ auto: true, controls: true }); myslider = $('#my-specific-slider').xxx; });
not sure if still need answer suggest use each().
$(function(){ $(".slider").each(function() { eleid = $(this).attr('id'); if (eleid) { eleid = $(this).bxslider({ auto: true, controls: true }); } } });
Comments
Post a Comment