惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

博客园 - leegool

常见XSD问题 EntitySpace 常用语句 抗投诉空间 C#用WebClient下载File时操作超时的问题 用C# 实现 Zen Cart 的用户密码加密算法 ASP.NET MVC 3 新特性 ASP.NET MVC 局部缓存实现 用户控件缓存 Partial Output Caching - leegool System.Web.Security.SqlMembershipProvider”要求一个与架构版本“1”兼容的数据库架构。 关于MarshalByRefObject的解释 MVC upload image MVC上传图片的例子 - leegool 清楚浏览器缓存 Overview of Full Text Stop Words(MSSQL全文索引的干扰词概括)MSSQL 全文索引的最小单词长度 JQuery性能优化 MS SQL 事务隔离级别 认识ASP.NET 中的 AppDomain 国外服务器上 中文成 显示乱码 Sharing cookie Across domain 跨域cookie访问 cookie跨域 web性能优化(最佳) EntitySpaces 2009 Trial Expire 异常
jQuery Custom Selector JQuery自定义选择器 - leegool
leegool · 2009-11-22 · via 博客园 - leegool

 什么是JQuery的选择器呢,详见JQuery中的Selector: http://docs.jquery.com/Selectors

比如 $("div:contains('John')").css("text-decoration", "underline");的contains选择器等等

JQuery自定义选择器的基本语法:

$.expr[':'].test = function(obj, index, meta, stack){
   
/* obj - is a current DOM element
       index - the current loop index in stack
       meta - meta data about your selector !!! 用来存参数值,详见带参数的自定义选择器。
       stack - stack of all elements to loop
   
       Return true to include current element
       Return false to explude current element
    */

};

// Usage:
$
('.someClasses:test').doSomething();
1.创建一个简单的自定义选择器(将返回"rel"标签不为空的元素)

$.expr[':'].withRel = function(obj){
 
var $this = $(obj);
 
return ($this.attr('rel') != '');
};
// 应用:
$
('a:withRel').css('background-color', 'yellow');
效果见:http://custom-drupal.com/jquery-demo/custom-selectors/
 
2. 创建带参数的自定义选择器,通过meta来实现.
语法:
$('a:test(argument)');
//meta would carry the following info: meta的格式如下(meta[3]对应的值是argument)
[
   
':test(argument)', // full selector
   
'test',            // only selector
   
'',                // quotes used
   
'argument'         // parameters
]

$

('a:test("arg1, arg2")');
//meta would carry the following info:
[
   
':test('arg1, arg2')', // full selector
   
'test',                // only selector
   
'"',                   // quotes used
   
'arg1, arg2'           // parameters
]
 
实例:
$.expr[':'].withAttr = function(obj, index, meta, stack){
 
return ($(obj).attr(meta[3]) != '');
};
应用:
$('a:withAttr(rel)').css('background-color', 'yellow');

 参考地址:

http://jquery-howto.blogspot.com/2009/06/jquery-custom-selectors-with-parameters.html

http://jquery-howto.blogspot.com/2009/06/custom-jquery-selectors.html

http://www.softwareunity.com/jquery/JQueryMoreSelectors/