Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy aren't these two functions toggling on click event?
    primarykey
    data
    text
    <p>I'm trying to toggle two functions. When user clicks the pause button, the input fields are disabled, the label is text is changed to grey and the button changes to a different image. I thought I could use .toggle(), but I can't get the two functions to work either -- only the first one function runs (<code>pauseEmailChannel();</code>), not both on toggle click. I found the even/odd clicks detection script <a href="https://stackoverflow.com/questions/4911577/jquery-click-toggle-between-two-functions">here on SO</a>, but that is not "toggling" these two functions on the click event. My code may be ugly code, but I'm still learning and wanted to show how I am thinking -- right or wrong. At any rate, can someone give me a solution to how to do this? I didn't think it would be too difficult but I'm stuck. Thanks.</p> <p>HTML </p> <p>jQuery</p> <pre><code> $(".btn_pause").click(function(){ var count = 0; count++; //even odd click detect var isEven = function(num) { return (num % 2 === 0) ? true : false; }; // on odd clicks do this if (isEven(count) === false) { pauseEmailChannel(); } // on even clicks do this else if (isEven(count) === true) { restoreEmailChannel(); } }); // when user clicks pause button - gray out/disable function pauseEmailChannel(){ $("#channel-email").css("color", "#b1b1b1"); $("#notify-via-email").attr("disabled", true); $("#pause-email").removeClass("btn_pause").addClass("btn_disable-pause"); } // when user clicks cancel button - restore default function restoreEmailChannel(){ $("#channel-email").css("color", "#000000"); $("#notify-email").attr("disabled", false); $("#pause-email").removeClass("disable-pause").addClass("btn_pause"); $("input[value='email']").removeClass("btn_disable-remove").addClass("btn_remove"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload