An ON/OFF switch using bootstrap and jQuery

See: http://gneady.com/creating-an-onoff-switch-using-bootstrap-and-jquery

HTML

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<div class="btn-group" id="toggle_event_editing">
	<button type="button" class="btn btn-info locked_active">OFF</button>
	<button type="button" class="btn btn-default unlocked_inactive">ON</button>
</div>
<div class="alert alert-info" id="switch_status">Switched off.</div>

JavaScript

$('#toggle_event_editing button').click(function(){
	if($(this).hasClass('locked_active') || $(this).hasClass('unlocked_inactive')){
		/* code to do when unlocking */
        $('#switch_status').html('Switched on.');
	}else{
		/* code to do when locking */
        $('#switch_status').html('Switched off.');
	}
	
	/* reverse locking status */
	$('#toggle_event_editing button').eq(0).toggleClass('locked_inactive locked_active btn-default btn-info');
	$('#toggle_event_editing button').eq(1).toggleClass('unlocked_inactive unlocked_active btn-info btn-default');
});