click vs. blur
by Juan Lanus
HTML
<p>Steps: Click in the input box below to set focus. Then attempt to click on the "Add item" link. Notice that the "add" alert is not shown.</p>
<div id="items" style="margin-top:1em">
<input id="itemsInput" type="text" id="item"/>
</div>
<div style="margin-top:1em"><a href="#" id="addItem">Add item</a></div>
JavaScript
function onBlur() {
console.log('blur');
$('#item').remove();
}
function addItem() {
console.log('add');
}
$(document).ready(function() {
$('#itemsInput').blur(onBlur);
$('#addItem').mousedown(addItem);
});