Bind and Unbind
by Santosh Thakur
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<h1>Bind and Unbind</h1>
<a id="button" href="#">click</a>
<br>
<br>
<a id="toggle" href="#">unbind</a>
JavaScript
$(document).on('click', 'a#button', function () {
$(this).after('<span> hello</span>');
$('span').fadeOut(1000);
$('a#toggle').toggle(
function () {
$(this).text('rebind');
$('a#button').on('click.disabled', true);
},
function () {
$(this).text('unbind');
$('a#button').off('click.disabled');
}
);
});