我有这个代码在对话框中添加图像。当我单击按钮时,它会在第一次将图像添加到对话框中,但是当我第二次单击该按钮时,图像不会显示在对话框中。有什么问题?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog functionality</title>
<link
href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- CSS -->
<style>
.ui-widget-header,.ui-state-default,ui-button {
background: #b9cd6d;
border: 1px solid #b9cd6d;
color: #FFFFFF;
font-weight: bold;
}
</style>
<!-- Javascript -->
<script>
$(function() {
//Button function
$("#button").click(function(){
$('<div id="dialog" title="title">Imageselected</div>').dialog({
resizable:false,
buttons: {"Enrol": function(){
$(this).dialog('close');
},
"CancelEnrol": function()
{
$(this).dialog('close');
}
}
});
$('#dialog').append('<img src="https://www.google.co.in/logos/doodles/2014/world-cup-2014-1-6584893165273088-res.png"/><br/>').append($(this).html());
});
});
</script>
</head>
<body>
<input type="button" id="button" value="Reset"/>
</body>
</html>