tags:

views:

72

answers:

2

How can I match all a-tags which have a font-size of 70%?

<a href="/tag/customersproducts" style="font-size: 70%; text-decoration: none;">customersproducts</a> 
<a href="/tag/dealers" style="font-size: 70%; text-decoration: none;">dealers</a> 
<a href="/tag/dealershops" style="font-size: 101%; text-decoration: none;">dealershops</a> 
<a href="/tag/dealersvendors" style="font-size: 120%; text-decoration: none;">dealersvendors</a> 
<a href="/tag/deliverymethods" style="font-size: 70%; text-decoration: none;">deliverymethods</a> 
<a href="/tag/departements" style="font-size: 70%; text-decoration: none;">departements</a> 
<a href="/tag/departments" style="font-size: 104.545%; text-decoration: none;">departments</a>

This does not work:

$('a[style*=font-size:70%]')

This is the page: http://cakeapp.com/tags/all with installed jQuery for testing...

+5  A: 

What you want is a filter:

$('a').filter(function() { return this.style.fontSize == '70%' })
David Hedlund
+1 - clearly less *duh* than my now-deleted solution <smacks self in face>.
karim79
Thank you for the generic approach! (.style.fontSize)
powtac
+1  A: 

The style attribute isn't a string, so that type of selector won't work (in fact, the console in Chrome and Firefox both say "indexOf is not a function" when trying this one).

I don't know how much control you have over this, but have you considered making those sizes a set of classes instead? It looks like you're calculating each size on the fly, so you might have to do some grouping/rounding to make that work. Alternatively, when you're creating those inline styles, could you also attach a class to items at 70% at the same time?

Brother Erryn