我是javascript的新手,并且一直在使用JQuery库。我有一个对话框,当我单击页面上的按钮时,该对话框应该打开。那部分工作正常但是当我在对话框内单击提交按钮时添加了javascript以关闭对话框时,对话框根本不会打开。 (工作正常是除Internet Explorer之外的所有浏览器)。你们能帮忙吗?这是我的代码:
<script>
$(function(){
$(".callparser").click(function (e) {
$(".parserinformation").dialog({
modal: true,
minHeight:400,
minWidth: 580,
open: function (e, ui) {
var $container = $(this);
$container.find('#close').click(function(){
$container.dialog("close");
});
},
beforeClose: function (e, ui) {
var $container = $(this);
$container.find('#close').unbind('click');
},
});
});
});
</script>
这是html(简化):
<input type="button" name="Parser" class="callparser" value="Parser"/>
<div class="parserinformation" style="display: none;">
<div class="addtofolder">
<input type="submit" id="close" class="addtofolderbutton" value="Private" onclick="$.jGrowl('Your product has been added!')">
</div>
</div>
答案 0 :(得分:2)
尝试没有最后一个逗号(,
),IE在最后一个元素之后不喜欢它。
<script type="text/javascript">
$(function(){
$(".callparser").click(function (e) {
$(".parserinformation").dialog({
modal: true,
minHeight:400,
minWidth: 580,
open: function (e, ui) {
var $container = $(this);
$container.find('#close').click(function(){
$container.dialog("close");
});
},
beforeClose: function (e, ui) {
var $container = $(this);
$container.find('#close').unbind('click');
}
});
});
});
</script>
<input type="button" name="Parser" class="callparser" value="Parser"/>
<div class="parserinformation" style="display: none;">
<div class="addtofolder">
<input type="submit" id="close" class="addtofolderbutton" value="Private" onclick="$.jGrowl('Your product has been added!')">
</div>
</div>