Change 2 images to one text onClick

前端 未结 1 726
Happy的楠姐
Happy的楠姐 2021-01-16 20:33

When a user clicks on either thumbs_up or thumbs_down, those 2 icons should be replaced with a text like \'You voted\'. How do I do that?

           


        
1条回答
  •  时光取名叫无心
    2021-01-16 21:21

    Add this in an asset file

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

    What this does is add the text You voted before the thumbsdown div and then remove the div afterwards. There's no single right way to do this so it's up to you how.

    0 讨论(0)
提交回复
热议问题