click vs. blur

by slolife

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 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() {
    $('#items').delegate('input','blur', onBlur);
    $('#addItem').click(addItem);
});