You can do this in two ways.
The first is to add the html attribute to link_to:
<% @video.phrases.each do |phrase| %> <div class = "span4" id ="comment" > <%= phrase.content %> </div> <%= link_to (image_tag("ff.png", :size=> "32x32" ), html => {:onclick => "$('#video_div').html('CONTENTS OF HTML');"} :remote => true %> <% end %>
Second, separate Javascript from Ruby:
<% @video.phrases.each do |phrase| %> <div class = "span4" id ="comment" > <%= phrase.content %> </div> <%= link_to (image_tag("ff.png", :size=> "32x32" ) :remote => true %> <% end %> <script type="text/javascript"> $('a').click(function(){ $("#video_div").html('CONTENTS OF HTML'); ); </script>
If you want the contents of the link tag, replace 'CONTENTS OF HTML'
with $(this).html()
source share