如何不选择最后一个元素 [英] How not to select the last element

查看:87
本文介绍了如何不选择最后一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在jquery/html/php中构建一个类似Web应用程序的Twitter.当用户向下滚动到页面末尾时,将增加更多的twits负载(就像在twitter上一样).我的问题是,在每个twit div中都有一个div(类.details),它显示对原始twit的答复,并且该答复twit也具有与原始twit相同的类.

So I am building a twitter like web app in jquery/html/php. When I user scrolls down to the end of the page more twits load (just like on twitter). The problem I have that inside each twit div there is a div (class .details) that is showing reply to the original twit, and that reply twit also has the same class as the original twit.

用代码更好地解释:

<div id="twit_id_{$twits[i].TID}" class="twit">    
    twit content
    <div>
        <div class="details">
            <div id="twit_id_{$twits[i].TID}" class="twit">
                twit content
            <div>
        </div>

通过这个jquery,我得到了最新的twit id,并将其发送到php,但是我不想从详细信息中获取该id.我需要页面中的最后一个ID,而不是详细信息中的ID.

And with this jquery I get the latest twit id and send it to php, but I don`t want the id from the details. I want the last id from the page, but not the id inside details.

var end_id = $(".twit:last").attr("id");

我尝试了类似的方法,但是没有用.

I tried something like this, did not work.

var end_id = $(".twit:last").not('.details').attr("id");

推荐答案

您很亲密:

var end_id = $(".twit:not(.details .twit):last").attr("id");

[edit]走近一点,发现这就是您想要的.

[edit] Looked a bit closer and realised that this is what you want.

JSFiddle: http://jsfiddle.net/wUv8k/

JSFiddle: http://jsfiddle.net/wUv8k/

这篇关于如何不选择最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆