In JSSOR, how to access the current caption via Ja

2019-02-18 17:14发布

问题:

I would like to pass a value from a slide out of JSSOR to other parts of the DOM.

Markup:

  <div class="slide">
    <img data-u="image" src="bilder/bild2.jpg" />
    <div class="caption" data-u="caption" ><p>Caption text</p></div>
  </div>

JS:

   jssor_slider1.$On($JssorSlider$.$EVT_PARK,function(slideIndex,fromIndex){
     $(".outer-caption").text(currentCaption);
   });

The custom JSSOR Event, EVT_PARK, works fine. But what's missing is how to get the caption of the current slide and put it into the variable currentCaption. How to do that?

And if so, where could I have found that out on my own?

回答1:

Please have a full test of following code,

  <div class="slide">
    <img data-u="image" src="bilder/bild2.jpg" />
    <div class="caption" data-u="caption" id="caption-slide-0"><p>Slide 0 Caption</p></div>
  </div>

   jssor_slider1.$On($JssorSlider$.$EVT_PARK,function(slideIndex,fromIndex){
     $("#outer-caption").text($("#caption-slide-" + slideIndex).text());
   });


标签: jssor