how make image clickable in rails view page.i tried in index.html.erb file, still not coming.
below code written.
<tbody> <% @messages.each |t| %> <tr> <td><%= t.from %></td> <td><%= t.subject %></td> <td id ="message"><%= image_tag("note.gif")%></td> <script type="javascript"> jquery("#message").click(function() { jquery("#message").html("<%=t.message%>") }); </script> <td><%=t.created_at.strftime("%b %d, %y")%></td> <td><%= link_to 'destroy', t, method: :delete, data: { confirm: 'are sure?' } %></td> </tr> <% end %> </tbody>
i don't know you're trying do, should you:
.... <td><img src="http://www.designchemical.com/lab/media/images/img_swap_off.png" alt="" class="img-swap"></td> .... $ -> $(".img-swap").live "click", -> if $(this).attr("class") "img-swap" @src = @src.replace("_off", "_on") else @src = @src.replace("_on", "_off") $(this).toggleclass "on"
Comments
Post a Comment