我目前可以使用:
$results.find('a[href$=".doc"]')
以编辑原因查找以.doc结尾的任何内容。但是,这似乎是区分大小写的,即如果文档以.DOC或.Doc结尾,则不会找到它们。是否有可能使这种情况不敏感?
答案 0 :(得分:8)
您必须创建一个不区分大小写的函数。
$results.find('a').filter(function(){return /\.doc$/i.test(this.href);});
也可以枚举选择器中的所有8个案例,但这不容易扩展。
$results.find('a[href$=".doc"],a[href$=".doC"],a[href$=".dOc"],a[href$=".dOC"],a[href$=".Doc"],a[href$=".DoC"],a[href$=".DOc"],a[href$=".DOC"]')
答案 1 :(得分:0)
尝试这个我不确定:
$results.find("a:regex(href, /\.doc$/i)")
但是这适用于所有标签,所以你可以用$ results
来使用它$("a:regex(href, /\.doc$/i)")