我使用的模式从引导如何从引导模式
<div aria-hidden="hide" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 id="myModalLabel" class="modal-title"></h4>
</div>
<div id="myModalBody" class="modal-body modalScroll"></div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
</div>
</div>
</div>
</div>
这是我的主要模式对话框赶上事件,我发送一些信息,并显示模式,当我需要的时刻来通知用户。但我的想法是使用这种模式来显示图像,当用户选择一个我会保存为头像。因此,我创建功能象下面这样:
<script>
$('#avatar').click(function() {
showMessage();
});
$('#eee').on('click', function() {
alert('333');
});
function showMessage(){
var txto = '<div id="eee">test me test</div>';
$('#myModalLabel').append('Coose Your avatar');
$('#myModalBody').append(txto);
$('#myModal').modal('show');
}
</script>
现在,当我去页面上,点击DIV ID =头像我会看到模式窗口,但是当我点击:考我,我都没有结果。那么有没有办法做到这一点?
这个问题的答案的问题是[事件委托( http://stackoverflow.com/questions/1687296/what-is-dom-event-delegation) – 2014-08-28 22:26:07