讲师中心 微信公众号
AI工具推荐 视频效率加速

JSLite在线手册

浏览10717
更新时间2022-04-11

如有疑问欢迎到这些地方交流,欢迎加入JSLite.io组织团伙共同开发!

filter

筛选出与指定表达式匹配的元素集合。
filter(selector)
filter(function(index){ ... }) 筛选出与 非 指定表达式匹配的元素集合。

$("div").filter("#box") //⇒ self 在所有的div对象中选择器为 #box 的过滤出来。

$("#select option").filter(function(idx){
    console.log(this.selected)
    return this.selected
})
//上面这种方法跟 not(function(index){ ... })  是一样的

not

not(selector)   ⇒ collection
not(collection)   ⇒ collection
not(function(index){ ... })   ⇒ collection
筛选出与 非 指定表达式匹配的元素集合。它的作用刚好与 filter 相反,返回。

$("#select option").not(function(idx){
    console.log(this.selected)
    return this.selected
})
//⇒ [哈哈3]
$("input").not("#input") //⇒ 返回除去 匹配到的#input

$('input').not(function(){
    console.log(this.type)
    return this.type=="text"
})

精品课程

更多
前端入门_HTML5
前端入门_HTML5

共29课时 | 65.3万人学习

CSS视频教程-玉女心经版
CSS视频教程-玉女心经版

共25课时 | 41.5万人学习

JavaScript极速入门_玉女心经系列
JavaScript极速入门_玉女心经系列

共43课时 | 77.1万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn