使用带有 JQuery 的通配符匹配属性值
Matching attribute values using wildcards with JQuery
我有一个这样的选择器:
$('link[href="../../../target/test/css/index.css"]')
../target/
之后的部分可以是任何内容。如何在 jquery 中指定通配符?这大约是我正在寻找的通配模式:
$('link[href="../../../target/**/*.css"]')
本身没有通配符 ,但您可以组合 starts with (^=) and ends with ($=) 选择器来实现您正在寻找的效果:
$('link[href^="../../../target/"][href$=".css"]');
jQuery 配备了许多有用的属性选择器,可以帮助解决此类问题——您可以在 https://api.jquery.com/category/selectors/attribute-selectors/.
查看它们
我有一个这样的选择器:
$('link[href="../../../target/test/css/index.css"]')
../target/
之后的部分可以是任何内容。如何在 jquery 中指定通配符?这大约是我正在寻找的通配模式:
$('link[href="../../../target/**/*.css"]')
本身没有通配符 ,但您可以组合 starts with (^=) and ends with ($=) 选择器来实现您正在寻找的效果:
$('link[href^="../../../target/"][href$=".css"]');
jQuery 配备了许多有用的属性选择器,可以帮助解决此类问题——您可以在 https://api.jquery.com/category/selectors/attribute-selectors/.
查看它们