Radu033 Radu033 - 1 year ago 76
CSS Question

How do I affect only some items in my array Jquery

My Wordpress posts shows images, all images have the .aligncenter class.
I would like the images which are less than 400px to have the

style and to reduce their size to 40%.

I tried it this way:

var size = jQuery(".aligncenter").width();
if(jQuery( size < 400)) {
'display' : 'inline-block',
'width' : '40%'

This script affects all images in the post, not only the ones that are less than 400px. How can I affect only images that are less than 400px?

Answer Source
$(".algincenter").each(function(){ if($(this).width()<400){$(this).css(...) } })
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download