0

特定の div の index() 値を取得する方法を見つけようとしました…</p>

基本的な 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>

ここで私が試したコード:

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

どうもありがとうございます!どんな助けでも大歓迎です…</p>

wbrレオ

4

1 に答える 1