选择具有以字符串开头的类的元素

选择具有以字符串开头的类的元素

问题描述:

是否可以选择具有以字符串开头的类的元素

Is it possible to select a element that has a class that starts with a string?

 .element[class^="icon-"]{
   ...
 }

但是当类在另一个类或其他任何类型之前失败:(

but it fails when the class is preceded by another class or whatever :(

是的,你可以!

.element[class^='icon-'],
.element[class*=' icon-'] {
  ...
}

查看实际操作: http://jsfiddle.net/caio/mxUxR/