For some reason, it is much easier for me if it is possible to select all the divs that match a particular set of similar style attributes.
Example of div that I want to select
<div style="background-image: url(http://localhost/website/images/template/markers/cluster.png); height: 34px; line-height: 34px; width: 34px; text-align: center; cursor: pointer; color: rgb(255, 255, 255); position: absolute; font-size: 12px; font-family: Arial, sans-serif; font-weight: bold; top: 78.15521871251985px; left: 725.3256078213453px; background-position: 0px 0px; ">15</div>
Other than this div, other divs that needs to be selected can be similar to this one, but with say different height
and top
left
positions. However, the good thing is that the background-image url()
remains the same.
How can this selection be made with jQuery? Thank you !!
Surrounding Code Easier to provide a screencap
parent > child
) with some reference element as their parent. Also, it's quite probable that Google Maps API provides a method to conveniently retrieve all markers at once - Marat Tanalin 2012-04-04 23:25
#map_canvas
is generated either by Google Maps API V3 or the Gmap library that I'm usin - Nyxynyx 2012-04-04 23:32
I don't think it's a good idea, but you can select elements by specific inline style with this:
$('div[style*="height: 34px"]')
"height: 34px;"
, for example "line-height: 34px"
Esailija 2012-04-04 23:26
$('div[style*=" height: 34px"]')
works because background-image is always the first style - binarious 2012-04-04 23:31
$('div[style*="background-image: url(http://localhost/website/images/template/markers/cluster.png);"]')
BUT yuk!binarious 2012-04-04 23:33
"height: 34px"
is not the same as "height:34px"
Joseph 2012-04-04 23:34