//NOT WORKING jQuery
function controls(id) {
if (id === "#button_start") {
$('#button_start').prop('disabled', false);
$('#button_stop').removeProp('disabled');
// testing event
$('#button_start').on('click',function() {
$(this).prop('disabled', false);
});
$('#button_stop').on('click', function(){
$(this).removeProp('disabled');
});
// You can define your play statements here
//console.log(id);
} else {
$('#button_stop').prop('disabled', true);
$('#button_start').removeProp('disabled');
// testing
$('#button_stop').click(function() {
$(this).prop('disabled', true);
});
$('#button_start').click(function(){
$(this).removeProp('disabled');
});
// You can define your stop statements here
//console.log(id);
}
}
/*WORKS as expected javascript
function controls(id) {
if (id === "button_start") {
document.getElementById('button_start').setAttribute('disabled','disabled');
document.getElementById('button_stop').removeAttribute('disabled','disabled');
// You can define your play statements here
console.log(id);
} else {
document.getElementById('button_stop').setAttribute('disabled','disabled');
document.getElementById('button_start').removeAttribute('disabled','disabled');
// You can define your stop statements here
console.log(id);
}
}
*/
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.