Javascript not working - changing image to text on click

匿名 (未验证) 提交于 2019-12-03 01:14:02

问题:

I've asked a question recently on how to change 2 icons to text on click. The solution worked for a while, but now it's not working. Is there another way to do it or is the problem in the code? I face the problem with other scripts very often.

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 output

   

icons.js

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

回答1:

If it was working before, the problem is likely an issue with Turbolinks:

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!