javascript - After the jquery object is defined as a jquery variable, how to use: gt this (there may be a problem with the expression)
黄舟
黄舟 2017-05-16 13:35:42
0
2
568

$("li:gt(2)") can be used, but a long time ago I saw a jquery variable converted to XX and then used:gt(2), such as var $li=$(" li"), I need to use: gt(2) based on the $li variable. I don’t know if you understand what I mean. I am looking for an answer. I saw it on a blog a long time ago, but I can’t remember it.

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
左手右手慢动作
$li.filter(':gt(2)')

Is this so?

伊谢尔伦

jquery itself does not have this method, only this selector, but you can extend it

$.fn.gt = function(num){
    var after = [];
    this.each(function(i){
        if(i>=num){
           after.push(this);
        }
    });
    return after;
}
$.fn.lt = function(num){
    var before = [];
    this.each(function(i){
        if(i<num){
           before.push(this);
        }
    });
    return before;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!