As per my comment you are trying to add the class to "img" which is undefined. Either switch that out so you have
image.addClass('classname')
Or since it's a short selector just insert that
$('img').addClass('classname')
Also make sure that the jQuery call is being made within a $(document).ready(...)
call