jquery - How to toggle two buttons on mouse hover? -


i've 2 buttons:
1 - follow
2 - unfollow

at first glance follow button displayed , when hover on follow button, want make follow button disappear , unfollow button appear, after once hovered on unfollow button want follow button appear , unfollow button dispear, how do it?

feed backs welcomed.

html code

<div class="btn-follow">follow</div> <div class="btn-unfollow">unfollow</div> 

css code

.btn-follow {     color: #fff;     background-color: #38b7ea;     padding: 5px 0;     width: 100px;     margin: 0 auto;     border-radius: 20px; } .btn-unfollow {     color: #fff;     background-color: #a5becb;     padding: 5px 0;     width: 100px;     margin: 0 auto;     border-radius: 20px; } 

an alternative , more optimal solution said can done same button below:

demo here

html

<button id="followunfollow" class="followunf follow">follow</button> 

js

$(document).ready(function(){        $('#followunfollow').on('click',function()        {            if($(this).hasclass('follow'))                $(this).removeclass('follow').addclass('unfollow').text('unfollow');            else                $(this).removeclass('unfollow').addclass('follow').text('follow');                   }); }); 

update

if want same on hover instead of click can change .on('click' hover below:

$('#followunfollow').hover(function(){   ...... }); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -