感谢那些回答我问题的人。两个答案都非常有帮助。
为了帮助自己理解您的答案,我在小提琴中玩弄这个。我想我也会分享 Fiddle 作为答案,希望能帮助其他人理解这一点,以防你像我一样,只能通过视觉示例来学习。
https://jsfiddle.net/zf3g22um/2/
HTML
<button id="add-reg-bound-element">Add Regularly-Bound Element</button>
<button id="add-doc-bound-element">Add Document-Bound Element</button>
CSS
.reg-bound-element, .doc-bound-element {
font: 600 14px sans-serif;
height: 100px;
line-height: 100px;
text-align: center;
width: 300px;
}
.reg-bound-element {
background-color: #BBB;
&:before {
content: 'Regularly-Bound Element';
}
}
.doc-bound-element {
background-color: green;
color: white;
&:before {
content: 'Document-Bound Element';
}
}
JS
//////////////////////////
// REGULARLY BOUND ELEMENT
//////////////////////////
$('#add-reg-bound-element').on('click', function() {
$('html').append('<div class="reg-bound-element"></div>');
});
$('.reg-bound-element').on('click', function() {
alert('Regular binding works!');
});
/////////////////////////
// DOCUMENT BOUND ELEMENT
/////////////////////////
$('#add-doc-bound-element').on('click', function() {
$('html').append('<div class="doc-bound-element"></div>');
});
$(document).on('click', '.doc-bound-element', function() {
alert('Document binding works!');
});