jquery - What is wrong with this code? I am trying to find the width of each items image, if the image is a certain width, apply a class to that item -
$(window).load(function() { $('#grid .item').each(function() { var imageh = $(this).children('img').attr('width'); if(imageh = 506) { $(this).addclass('d'); } else if (imageh = 250) { $(this).addclass('a'); } }); });
the page here - http://stable.dev.pixel-geeks.co.uk/news/
i trying create dynamic grid in wordpress. require system see image size has been uploaded, if image size meets criteria apply class container of image
it be
if(imageh == 506) { $(this).addclass('d'); } else if (imageh == 250) { $(this).addclass('a'); }
you not comparing,you assigning imageh
return true
Comments
Post a Comment