English 中文(简体)
接下来的顺序问题
原标题:Jquery next() problem

我有这一法典:

<div class="window-compl">
    <div class="window showincatalog showing">
    <h2>Text1</h2>
    </div>

    <div class="window">
    <h2>Text2</h2>
    </div>

    <div class="window showincatalog">
    <h2>Text3</h2>
    </div>

    <div class="window showincatalog">
    <h2>Text4</h2>
    </div>
</div>

在这项职能中,我使用(a)和(b)之前的挑选器:

function rotate(direction) {    
    var current = $( .showing );
    if (direction==0)
        var next = $( .showing ).prev( .showincatalog );
    else
        var next = $( .showing ).next( .showincatalog );
}

当所有支部都有集体表现时,它就会停下来,而当其中一方没有。

如果有人知道为什么不工作,那将是巨大的。

更新:我需要选编“showincatalog”和文本3,但(showing .next( .showincatalog )没有回报。

最佳回答

我认为,你们想要的是:

function rotate(direction) {
    var current = $( .showing ),
        next;
    if (direction == 0) {
        next = $( .showing ).prevAll( .showincatalog ).first();
    } else {
        next = $( .showing ).nextAll( .showincatalog ).first();
    }
    current.removeClass( showing );
    next.addClass( showing );
}

rel=“nofollow> See example here.

问题回答

我认为,我得到你们的再努力,而且我本人也一直在 st。 陷阱是,<代码>next要么获得下一个要素,要么无所作为。 如果你想要“与这一选择者相匹配的下一个要素”,则使用<代码>.next All(选择or ).first(。

这是因为你在法典中重新指出,你想要下一个包含<条码>的元素。 如果你要列入不从<代码>前()和<代码>next(电话中删除的碎片。

...... 我假定,你意味着什么被打破。 如果行为不同,你就应该回答你的问题。

http://api.jquery.com/next/“rel=“nofollow”>next。

The method optionally accepts a selector expression of the same type that we can pass to the $() function. If the immediately following sibling matches the selector, it remains in the newly constructed jQuery object; otherwise, it is excluded.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签