FANDOM


 
green
prohibit

This is a little test of the bindFirst plugin. There are two buttons here: The one on the left briefly turns the red surface green. And the button on the right turns the button on the left on and off. The code is here

This is the relevant bit:

var prohibit = false;
 
function turnGreen () {
    console.log('turnGreen');
    $('#red').css('background-color', 'green');
    setTimeout(function () {
        $('#red').css('background-color', 'red');
    }, 200);
}
 
function toggleTurnGreen (ev) {
    console.log('toggleTurnGreen:', prohibit);
    if (prohibit) {
        ev.stopImmediatePropagation();
    }
}
 
function setToggle () {
    $('#toggle').text((prohibit = !prohibit) ? 'permit' : 'prohibit');
}
 
$('#green')
.bind('click', turnGreen)
.bindFirst('click', toggleTurnGreen);
 
$('#toggle')
.bind('click', setToggle);

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.