是否可以为带有通配符属性的属性名称使用通配符? [英] Is it possible to wildcard for an attribute name with a wildcarded attribute?

查看:140
本文介绍了是否可以为带有通配符属性的属性名称使用通配符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有 [src * = example] 选择所有具有包含'example'的'src'属性的HTML元素。是否可以定位任何属性,几乎导致属性的通配符?

I currently have [src*=example] that selects all HTML elements with a 'src' attribute containing 'example'. Is it possible to target any attributes, pretty much resulting in wildcarding for attributes?

或多或少,它会像 [ )* = example] ,可以找到包含example的任何属性的所有元素。

More or less, it would be something like [(any attribute)*=example] that would find all elements with any attribute containing 'example'.

$ b

推荐答案

否。在此日期之前没有这样的选择器。

NO. There's no such selector in css up to this date!

使用jQuery:

$('*').filter(function(){
   var selector = this;
     return $.grep(selector.attributes, function(attr) { 
        return attr.value.indexOf('example') !==-1 }).length > 0;
}).css('color','red');

这篇关于是否可以为带有通配符属性的属性名称使用通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆