$('#control-history-undo').click(function() { if (!$(this).hasClass('disabled')) { graph.historyUndo(); } return false; });