开发者

help with jQuery selector to find last DIV in the body that doesn't have fixed positioning

I am fighting this thing and cannot figure it out... can someone please help.

I want to find the last DIV in the BODY that: A) Is NOT a specified ID (the easy part); and B) Does NOT have fixed positioning (the part that's killing me)

Basically, I am looking for the last DIV in the BODY that's part of the flow, so I can add a bit of margin-bottom.

this is where I am at so far:

$(theBody).children('div').not('#toolbar').not(':fixed').find(':last');

$.expr[':'].fixed = functio开发者_JAVA百科n(obj, index, meta, stack){
    if ($(obj).css('position')=='fixed') {
        return true;
    } else {
        return false;
    }
};

it's not working, and I think the custom selector is overthinking it.... I just dunno how to work it in there.

Thanks in advance, folks!


First thing you need to do is define the custom selector above the code where you use it :)

The selector I believe you want is...

$('body > div:fixed:not(#toolbar):last')

jsFiddle.

I also provided a terser custom selector...

$.expr[':'].fixed = function(obj){
   return $(obj).css('position') == 'fixed';
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜