Home › Forums › JavaScript › JQuery index(); of parent-DIV
- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
August 2, 2013 at 1:35 pm #145527
Leonhard Ortner
ParticipantHello People,
i have tried to figure out how to get the index() value of a specific div…
Basic HTML:
<div class="rsContainer"> <div class="rsSlide rsActiveSlide"> <div class="rsContent" data-name="/A"></div> </div> <div class="rsSlide"> <div class="rsContent" data-name="/B"></div> </div> <div class="rsSlide"> <div class="rsContent" data-name="/C"></div> </div> <div class="rsSlide"> <div class="rsContent" data-name="/D"></div> </div> <div class="rsSlide"> <div class="rsContent" data-name="/E"></div> </div> <div class="rsSlide"> <div class="rsContent" data-name="/F"></div> </div> </div>
so here the code i have tried:
var pathname = "/B"; // this is a random one of the data-name values var currentslide = $(".rsActiveSlide").find(".rsContent").data("name"); // this is active var rightone = $(".rsContainer").find(".rsContent" + "[data-name='" + pathname +"']"); // this should be the active // here is the problem, all i need is the index(); of the parent.DIV (.rsSlide) if (currentslide != pathname) { goTo(index-of-rightone's-parent); } // so i could do: goTo(index); and the Slider will set the Slide which contains the "rightone" to be active
Could someone help me? Thx you very much! Any Help is appreciatet…
wbr Leo
August 3, 2013 at 6:21 am #145575Leonhard Ortner
ParticipantHello Guys,
got this working:
// SLIDE TO RIGHT SLIDE // setTimeout for Slider to get rdy setTimeout(function() { // pathname = url var pathname = window.location.href; // current active slide var currentslide = $(".rsActiveSlide").find(".rsContent").data("slide-infourl"); if (pathname != currentslide) { // Select the right Slide width the corresponding URL in DATA-INFOURL var rightone = $(".rsContainer").find(".rsContent" + "[data-slide-infourl='" + pathname +"']").parent().index(); // slider goTo slider.goTo(rightone); } }, 500);
wbr leo
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘JavaScript’ is closed to new topics and replies.