user2232681 user2232681 - 4 months ago 15
CSS Question

How to find an element by style attribute?

I am having trouble retrieving elements by style attribute.
I have a

with several
elements and I would like to find the one with the style atribute having a value
. I have tried to approach this in several ways, including the following, but I keep getting an empty object. I have no problem with a title attribute. Not sure what I am doing wrong.



<ul class="bjqs" style="height: 200px; width: 100%;">
<li class="bjqs-slide" style="height: 200px; width: 100%; display: list-item;">


Two problems:

  1. In your HTML there is a space between "display:" and "list-item".
  2. Your selector needs to be wrapped with quotations "".

Simply change your selector to include this space and wrap it in quotes:

$('li[style*="display: list-item"]')

JSFiddle demo.