jquery - Selector based on css property -


is possible select elements based on value of css property. example:

css rules:

div.blockwithborder { border: 1px solid red; } 

html markup:

<div id="a" class="blockwithredborder">...</div> <div id="b" style="border: 5px dashed red">...</div> <div id="c" style="border: 2px solid #ff0000">...</div> 

i want find div elements red border. a, b , c match query.

you this, mean getting computed style value each element querying against expensive operation.

here's example:

var = [].slice.call(document.queryselectorall("a"));  var redlinks = a.filter(function(i){   window.getcomputedstyle(i);   var color = i.style.bordercolor.tolowercase();   return (color === 'red' || color === '#f00' || color === '#ff0000') ? : false; }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -