$(document).on('click', '.item', function () {
var title = $(this).text();
var obj = $("<div class='line'> - </div><div class='crumb'>" + title + "</div>");
obj.appendTo('#path');
});
.line{
display:inline-block;
margin:0 2px;
}
.crumb{
display:inline-block;
padding:0 7px;
background:gold;
}
.item{
cursor:pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='path' id='path'>
<div class='crumb'>home</div>
</div>
<br>
<div class='store'>
<div class='item'>lorem</div>
<div class='item'>ipsum</div>
</div>
Click on lorem
, ipsum
, lorem
...
Why there is an extra space (about 2px) between the first crumb (home
) and the first line (-
) compared to all next of them?