How could someone replicate the Follow/Unfollow hover action on Twitter's website using Twitter Bootstrap?

前端 未结 2 1457
长情又很酷
长情又很酷 2021-01-07 01:17

When you look at who you\'re following on Twitter, the buttons change from Follow to Unfollow (switch from green to red AND change from check-mark to x-mark).

How wo

2条回答
  •  爱一瞬间的悲伤
    2021-01-07 02:15

    bootstrap-buttons.js is a new feature in Twitter Bootstrap. But you can also do it manually using jQuery.

    Here's a button (green)

    
    

    now, you need to change the class and content of the button on hover,:

    // Javascript File
    function change_btn(){
    
    $('.follow').removeClass("success");
    $('.follow').addClass("danger");
    $('.follow').html("✗ UnFollow");
    
    }
    

    This script will remove and add classes to change the background of the button and also changes the content in it.

提交回复
热议问题