Reputation: 47
I have a jQuery Light Slider and it works fine. I want to access active element name. I try to print active image name in console but its not working.
$( document ).ready(function() {
$('#lightSlider').lightSlider({
gallery: true,
item: 1,
loop: true,
slideMargin: 0,
thumbItem: 9,
onAfterSlide: function (el) {
console.log(el);
},
});
});
This code gives...
jQuery.fn.init
[ul#lightSlider.lightslider_left.slider_ul.lightSlider.lsGrab.lSSlide,
context: document, selector: "#lightSlider", goToPrevSlide: ƒ,
goToNextSlide: ƒ, mode: ƒ, …]
...in every slide change but I'm not suppose to get the name of the image.
I appreciate your ideas and helps
Upvotes: 0
Views: 1307
Reputation: 114
In Your case this might help! (just use this console.log() instead of yours!
$('#lightSlider').lightSlider({
gallery: true,
item: 1,
loop: true,
slideMargin: 0,
thumbItem: 9,
onAfterSlide: function (el) {
console.log($(el).find('.active img').attr('src'));
},
});
Upvotes: 1
Reputation: 2372
You can locate corrent active li's Image by following Jquery Code:
Try this:
$('#lightSlider').find(".active").find("img").attr("src");
Upvotes: 0