Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:16:23+00:00 2026-06-06T06:16:23+00:00

As you can see in this jsfiddle , I’m trying to make a toggle

  • 0

As you can see in this jsfiddle, I’m trying to make a toggle switch (a mute button) that

  1. displays the current setting, i.e. mute or unmute
  2. when hovered upon, displays the alternative

However, my problem is when the user clicks the button, instead of displaying the opposite button, it shows that opposite buttons hover state. I hope this is making sense, haha. Basically the interaction is:

  1. view button in unmute state
  2. hover over and see the mute icon
  3. click and see the unmute icon again, because it is the mute states hover image
  4. when the icon is not hovered upon, it displays the proper icon, i.e. mute

In the jsfiddle example, I want a click to display the button, not the :hover attribute… any help? I’m aware that this kinda thing can’t be handled by css alone.. (sorry if this seems confusing, ive been working in codespeak for a while today…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:16:25+00:00Added an answer on June 6, 2026 at 6:16 am

    Consider this alternative solution:

    • uses single button
    • manipulates .text() and .css() to change button attribute
    • custom toggler implemented because of special cases you require

    Here is the code:

    CSS:

    button { width: 200px; height: 60px; color: white; font-size: 20px; background-color: red; }
    

    HTML:

    <button class=''> Mute </button>
    

    JS:

    function unmute() {
        $('button').removeClass('muted');
        $('button').text('Unmute');
        $('button').css('background-color','blue');
    }
    function mute() {
        $('button').addClass('muted');
        $('button').text('Mute');
        $('button').css('background-color','red');
    }
    
    function customToggler() {
        if (disableToggle) return;
        if ($('button').hasClass('muted')) unmute(); else mute();
    }
    
    var disableToggle = false;
    
    $(document).ready(function() {
    
        customToggler();
    
        $('button').click(function() {
           disableToggle = true;
           customToggler();
        });
    
        $('button').mouseover(function() {  
            customToggler();
        }).mouseout(function() {  
            customToggler();
            disableToggle = false;
        });
    });
    

    —

    To see the above code in action, see http://jsfiddle.net/fwjz5/ Good luck!
    ​

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code http://jsfiddle.net/noppanit/8D7QN/ As you can already see that the text overflows
I compiled this jsFiddle demo so that you can see what i am going
If you check this: http://jsfiddle.net/QbMmX/1/ Then you can see that the box(div element) is
If you goto http://jsfiddle.net/BT4Bk/ you can see that the dark bar is visible. This
Please see this : http://jsfiddle.net/ymSpY/ . If you can see <td> has an inner
I'm working with something like this: http://jsfiddle.net/Hh2Ht/ As you can see, I have a
You can see the example here: http://jsfiddle.net/8EHED/8/ This is a tricky problem because I
I have chart of winning positions. http://jsfiddle.net/DhcTV/4/ like this. As you can see the
http://jsfiddle.net/YaMhn/8/ ^^^^Take a look and see if you can help solve this Ok so
Please see this jsFiddle: https://jsfiddle.net/Wmq6f/ I have a textarea that has a background image,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.