In JSSOR, how to access the current caption via Javascript?

ぃ、小莉子 提交于 2019-12-19 09:19:27

问题


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());
   });


来源:https://stackoverflow.com/questions/23971335/in-jssor-how-to-access-the-current-caption-via-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!