Javascript无法正常工作 – 点击时将图片更改为文字

我最近问了一个关于如何在点击时将2个图标更改为文本的问题。 解决方案工作了一段时间,但现在它无法正常工作。 还有其他方法可以做到这一点,还是代码中的问题? 我经常遇到其他脚本的问题。

的application.js

//= require jquery //= require jquery_ujs //= require bootstrap //= require jquery.ui.all //= require jquery.turbolinks //= require jquery_nested_form //= require_tree . 

show.html.erb

 
true %>
true %>

HTML输出

   

icons.js

 $('.thumbsdown a, .thumbsup a').on('click', function() { $('.thumbsdown').before('You voted') $('.thumbsdown, .thumbsup').remove() }) 

如果之前有效,那么Turbolinks可能会出现问题:

 $(document).on("click", ".thumbsdown a, .thumbsup a", function() { $('.thumbsdown').before('You voted') $('.thumbsdown, .thumbsup').remove() });