The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript JQuery index(); of parent-DIV

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #145527
    Leonhard Ortner

    Hello 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 class="rsSlide">
            <div class="rsContent" data-name="/B"></div>
        <div class="rsSlide">
            <div class="rsContent" data-name="/C"></div>
        <div class="rsSlide">
            <div class="rsContent" data-name="/D"></div>
        <div class="rsSlide">
            <div class="rsContent" data-name="/E"></div>
        <div class="rsSlide">
            <div class="rsContent" data-name="/F"></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) {
    // 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

    Leonhard Ortner

    Hello Guys,

    got this working:

        // 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
        }, 500);

    wbr leo

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.