Add form side info on input
by nosfan1019
HTML
<div id='boss'>
<div>
<input type='text' class='aaa'>
<span></span>
</div>
<div>
<input type='text' class='bbb'>
<span></span>
</div>
<div>
<input type='text' class='ccc'>
<span></span>
</div>
</div>
<a href="#" class="fresh">clear</a>
<p></p>
CSS
body {
margin: 50px;
}
input {
display: inline-block;
margin: 30px 0;
}
p {
margin: 100px 0 0;
}
span {
margin: 0 0 0 10px;
}
JavaScript
$(function () {
$("body").mousedown(function(event) {
$('a').click(function() {
var foo = $(this).parent();
$(this).closest('div').next().children('input').focus();
foo.empty();
});
if ($(event.target).is('input')) {
$('#boss').find('span').empty();
$(event.target).siblings('span').html('<a href="#">yes</a>');
}
$('p').text(event.target.nodeName);
});
});