-2

我需要一个像这个例子这样的按钮

我应该用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");}      
        });
    }
  });

有什么变化需要有引导按钮?

4

1 回答 1

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 脚本,只需执行单击操作即可。

于 2013-08-05T21:35:20.770 回答