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

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -