I would like to change the image of a link with jquery. This is what I tried :
In my Haml file :
.selected
= link_to image_tag('/assets/unselected.png'), {:controller => Posts, :action => "update", :selected => true}, :id => "selected_post", :remote => true, :method => :put
After some stuff in my posts_controller, here is the update.js.coffee where I tried to change the image of the link with a new one called selected.png :
$("selected_post").attr 'src', '/assets/selected.png'
I does not work and if I call an alert with :
alert $("selected_post").attr 'src'
It sends "undefined".
I think I am missing something.