$('#btn').toggle(function(){ $('#div').data('off',false); }, function(){ $('#div').data('off',true); });