Javascript 单击按钮时隐藏div

Javascript 单击按钮时隐藏div,javascript,jquery,asp.net,html,Javascript,Jquery,Asp.net,Html,当用户点击“评论”按钮时 <input id="SubmitCommentsToInvoice" type="button" value="Comments" onclick="ShowCommentBox('<%: item.DBId %>', '<%: item.LabourOrPlant %>', '<%: item.ActivityDescription %>')" /> 将加载一个文本区域,其中包含一个提交按钮。当用户完成输入数据并

当用户点击“评论”按钮时

<input id="SubmitCommentsToInvoice" type="button" value="Comments" onclick="ShowCommentBox('<%: item.DBId %>', '<%: item.LabourOrPlant %>', '<%: item.ActivityDescription %>')" />

将加载一个文本区域,其中包含一个提交按钮。当用户完成输入数据并单击“提交”时,我希望该框消失。(返回正常屏幕查看)


函数SubmitButton(){
var commentBoxData=$('#').val();
WorkItemMgr.CommentBoxForInvoiceUpdates(id、人工或设备、commentBoxData、testForSuccess);
}
成功的功能测试(CommentsSuccessfullyUpdated)
{
如果(CommentSuccessfullyUpdated==“TRUE”)
{
//$('#'+IdCommentBox).hide();
//$(“#”).hide();只隐藏注释框需要隐藏整个内容
$(“#dialog”).dialog({modal:true}).hide();
//在这里,我想隐藏DIV(我的尝试如上所示)
}
else if(CommentSuccessfullyUpdated==“False”)
{
showLoadingImage.src=“../Images/X.png”;
}
}
我的尝试已经隐藏了textarea,但我想再次隐藏整个div并返回到屏幕的正常查看状态(摆脱模式:true)

使用jQuery:

$("#div_id").hide();
在jQuery中

 $('#BlankBox').hide();
在javascript中

document.getElementById("BlankBox").style.display='none';

我不认为这条线在做你认为它在做的事情:

$("#dialog").dialog({ modal: true }).hide();
这告诉对话框插件将
#dialog
初始化为一个新对话框(模式),然后告诉jQuery隐藏整个内容。如果此时
#dialog
已经是一个模式对话框,您只想隐藏它,请尝试以下操作:

$("#dialog").dialog("close");
这会告诉对话框插件隐藏(或关闭)现有对话框


通常,如果可能的话,您希望使用插件的本机功能,而不是尝试对其应用其他功能。在这种特殊情况下,最好告诉jQuery UI对话框隐藏自己,而不是尝试使用jQuery(它不知道对话框插件)隐藏div,因为它不知道该div是否有任何“特殊”之处(有另一个插件正在使用它…jQuery UI Dialog).

如果使用jQuery ui对话框,则应使用


如果您使用的是jqueryui对话框,请尝试使用:
$(“#dialog”).dialog({hide:1})

尝试以下操作:

<div id="dialog" title="Comments"  style="display:none;">   
  <textarea id="BlankBox" type="text" runat="server" rows="7" maxlength="2000" />     
  <input id="SubmitComment" type="button" value="Submit"/>
</div> 
$("#dialog").dialog('close');
<div id="dialog" title="Comments"  style="display:none;">   
  <textarea id="BlankBox" type="text" runat="server" rows="7" maxlength="2000" />     
  <input id="SubmitComment" type="button" value="Submit"/>
</div> 
$(function(){
   $('#SubmitComment').click(function(){
      $(this).closest('#dialog').hide();
   });
});