[英]show/hide the <div> tag is not working
我有一个超链接,它应该在 onclick 事件期间一一调用 3 个 JS 函数。
<form name = "bulkcontactfrm" method="POST" action="<%= servletPath %>>
<div id="saveDiv" layoutAlign="top" style="display:block;">
<table id="" align="left" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="javascript:void(0);" onclick="isAllowedToResubscribe(document.bulkcontactfrm); manipulateDIV(document.bulkcontactfrm); resubscribeCall(document.bulkcontactfrm);"> Re-Subscribe</zoniac:roundrect> </a>
</td>
</tr>
</table>
</div>
<div id="loadingDiv" class="cellWhiteBGFont" layoutAlign="top" style="display: block;"><p><img src="<%=ImageMappingManager.getImageName("imgLoading")%>" name = "b1"> <font size='3'><b>Please wait...<b></font></p>
</div>
</form>
JS函数如下:
// First function validate the data using ajax call
function isAllowedToResubscribe(form) {
//Client validation takes here
processAjaxRequestPost('ajaxRequestPost','SimpleHandler','getResubscribeEmailValidationDetails',emilIDStr,sourcefromStr);
}
// Second function hide the content in UI and show the Processing image in <DIV> tag
function manipulateDIV(form) {
hideSaveDiv();
showLoadingDiv();
}
function hideSaveDiv() {
//hide the Re-Subscribe hyperlink
document.getElementById('saveDiv').style.display='none';
}
function showLoadingDiv() {
//show the Processing image
document.getElementById('loadingDiv').style.display='block';
}
// Third function is for form submit using ajax call
function resubscribeCall(form) {
//processAjaxRequestPost('ajaxRequestPost','SimpleHandler','getResubscribeEmailDetails',emilIDStr,sourcefromStr);
}
单击超链接验证 function 调用并获取成功后,出现构造消息,单击构造上的确定。 但是<DIV>
标签并没有被隐藏,所以没有加载进度图像。
这里的代码有点乱,所以很难判断问题出在哪里,以及你在这里粘贴的内容是否正是你正在使用的。 但一种可能性是它没有正确定位 div,因为您在form
标记中缺少"
标记:
<form name = "bulkcontactfrm" method="POST" action="<%= servletPath %>>
应该:
<form name="bulkcontactfrm" method="POST" action="<%= servletPath %>">
快速测试似乎表明缺少的"
足以使 DOM 混乱以使document.getElementById()
无法正常工作。比较http://jsfiddle.net/nrabinowitz/n9S33/2/和http://jsfiddle.net/nrabinowitz /n9S33/3/看看这个在行动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.