2013-08-05 32 views
-2

我需要一個一個如下圖所示按鈕像this example引導嘰嘰喳喳像後續按鈕

我本來應該在Java腳本寫?

$('.following').hover(function(){ 
     $(this).text("Unfollow"); 
    },function(){ 
     $(this).text("Following"); 
    }); 
    //for toggle the class following/follow When click 
    $('.following').click(function(){ 
    $(this).toggleClass('following follow').unbind("hover"); 
    if($(this).is('.follow')){ 
     $(this).text("Follow"); 
    } 
    else{ 
    //binding mouse hover functionality 
     $(this).bind({ 
      mouseleave:function(){$(this).text("Following");}, 
      mouseenter:function(){$(this).text("Unfollow");}  
     }); 
    } 
    }); 

什麼樣的變化需要引導按鈕?

回答

0

您可以在CSS中做到這一點,像這樣:http://jsfiddle.net/Th4th/

.follow { 
    width: 100px; 
    height: 40px; 
    background-color: gray; 
} 
.follow:hover span {display:none;} 

.follow:hover:before { 
    content: "Unfollow" 
} 

我不認爲你需要的Java腳本的按鈕變化,只有採取點擊的動作。

+0

我想用bootstap clasess – Clear

+0

以及你給的鏈接有一個教程。那是行不通的? – Bobo

+0

http://www.techumber.com/2012/10/create-twitter-like-follow-and-unfollow.html – Clear