Javascript funktioniert nicht - das Bild wird beim Klicken in Text umgewandelt

Ich habe a gefragtFrage vor kurzem auf, wie man 2 Ikonen zum Text auf Klicken ändert. Die Lösung hat eine Weile funktioniert, aber jetzt funktioniert sie nicht mehr. Gibt es eine andere Möglichkeit oder liegt das Problem im Code? Ich stelle das Problem mit anderen Indexen sehr häufig gegenüber.

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

<div class="thumbsup">
<%= link_to image_tag('othericons/thumbsup_off.PNG', height: '20', width: '20', like_post_comment_path(comment.post_id, comment), method: :put, :remote => true %>
</div>

<div class="thumbsdown">
<%= link_to image_tag('othericons/thumbsdown_off.PNG', height: '20', width: '20', dislike_post_comment_path(comment.post_id, comment), method: :put, :remote => true %>
</div>

HTML-Ausgabe

<div class="thumbsup">
    <a data-method="put" data-remote="true" href="/posts/1/comments/4/like" rel="nofollow">
        <img alt="Thumbsup off" height="21" src="/assets/othericons/thumbsup_off.PNG" width="20" />
    </a>
</div>

<div class="thumbsdown">
    <a data-method="put" data-remote="true" href="/posts/1/comments/4/dislike" rel="nofollow">
        <img alt="Thumbsdown off" height="21" src="/assets/othericons/thumbsdown_off.PNG" width="20" />
    </a>
</div>

icons.js

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

Antworten auf die Frage(1)

Ihre Antwort auf die Frage