使用jQuery选择具有特定CSS的所有元素 [英] Select all elements that have a specific CSS, using jQuery

查看:150
本文介绍了使用jQuery选择具有特定CSS的所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery选择应用了特定CSS属性的所有元素?例如:

  .Title 
{
color:red;
rounded:true;
}

。应用程序
{
color:black;
rounded:true;
}

如何选择名为rounded的属性?



CSS类名非常灵活。

  $ ); 
$(。Caption)。corner();

如何将这两个操作替换为一个操作。可能是这样的:

  $(。*  - > rounded有没有更好的方法来做这个?



解决方案

您不能(使用CSS选择器)根据应用于它们的CSS属性选择元素。



如果你想手动做,你可以选择文档中的每一个元素,循环遍历它们,并检查你感兴趣的属性的计算值(这可能只适用于真正的CSS属性,而不是组成的舍入)。这也会很慢。



响应修改更新 - group selectors

  $(。Title,.Caption )。角(); 


How can I select all elements that have a specific CSS property applied, using jQuery? For example:

.Title
{
    color:red;
    rounded:true;
}

.Caption
{
    color:black;
    rounded:true;
}

How to select by property named "rounded"?

CSS class name is very flexible.

$(".Title").corner();
$(".Caption").corner();

How to replace this two operation to one operation. Maybe something like this:

$(".*->rounded").corner();

Is there any better way to do this?

解决方案

You cannot (using a CSS selector) select elements based on the CSS properties that have been applied to them.

If you want to do this manually, you could select every element in the document, loop over them, and check the computed value of the property you are interested in (this would probably only work with real CSS properties though, not made up ones such as rounded). It would also would be slow.

Update in response to edits — group selectors:

$(".Title, .Caption").corner();

这篇关于使用jQuery选择具有特定CSS的所有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆