Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

javascript - jQuery选择器正则表达式(jQuery selector regular expressions)

I am after documentation on using wildcard or regular expressions (not sure on the exact terminology) with a jQuery selector.(我正在阅读使用jQuery选择器使用通配符或正则表达式(不确定的确切术语)的文档。)

I have looked for this myself but have been unable to find information on the syntax and how to use it.(我自己一直在寻找,但一直无法找到有关语法和如何使用它的信息。) Does anyone know where the documentation for the syntax is?(有谁知道语法的文档在哪里?) EDIT: The attribute filters allow you to select based on patterns of an attribute value.(编辑:属性过滤器允许您根据属性值的模式进行选择。)   ask by Joel Cunningham translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use the filter function to apply more complicated regex matching.(您可以使用filter函数来应用更复杂的正则表达式匹配。)

Here's an example which would just match the first three divs:(这是一个与前三个div匹配的示例:) $('div') .filter(function() { return this.id.match(/abc+d/); }) .html("Matched!"); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="abcd">Not matched</div> <div id="abccd">Not matched</div> <div id="abcccd">Not matched</div> <div id="abd">Not matched</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...