检查是否有任何元素包含某些css样式 [英] check if any element contains certain css style

查看:121
本文介绍了检查是否有任何元素包含某些css样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道要检查包含任何css样式的元素的检查过程。

I am wondering to find out the checking process for an element to contain any css style.

我有以下html代码:

I do have below html code:

<ul id="sample">
    <li style="left:-100px">text 1</li>
    <li style="left:0px">text 2</li>
    <li style="left:100px">text 3</li>
</ul>

我想找出其样式为0px的li,然后再想申请那个李的风格。

I want to find out the "li" whose style left is 0px and then want to apply any more style to that li.

谢谢

推荐答案

$("#sample li").filter(function() {
  return $(this).css('left') == "0px";
}).css('color', 'blue');

这篇关于检查是否有任何元素包含某些css样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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