繁体   English   中英

显示/隐藏<div>标签不工作</div><div id="text_translate"><p>我有一个超链接,它应该在 onclick 事件期间一一调用 3 个 JS 函数。</p><pre> &lt;form name = "bulkcontactfrm" method="POST" action="&lt;%= servletPath %&gt;&gt; &lt;div id="saveDiv" layoutAlign="top" style="display:block;"&gt; &lt;table id="" align="left" border="0" cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;a href="javascript:void(0);" onclick="isAllowedToResubscribe(document.bulkcontactfrm); manipulateDIV(document.bulkcontactfrm); resubscribeCall(document.bulkcontactfrm);"&gt;&amp;#160;Re-Subscribe&lt;/zoniac:roundrect&gt;&amp;#160;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;div id="loadingDiv" class="cellWhiteBGFont" layoutAlign="top" style="display: block;"&gt;&lt;p&gt;&lt;img src="&lt;%=ImageMappingManager.getImageName("imgLoading")%&gt;" name = "b1"&gt;&amp;nbsp;&amp;nbsp;&lt;font size='3'&gt;&lt;b&gt;Please wait...&lt;b&gt;&lt;/font&gt;&lt;/p&gt; &lt;/div&gt; &lt;/form&gt;</pre><p> JS函数如下:</p><pre> // 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 &lt;DIV&gt; 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); }</pre><p> 单击超链接验证 function 调用并获取成功后,出现构造消息,单击构造上的确定。 但是&lt;DIV&gt;标签并没有被隐藏,所以没有加载进度图像。</p></div>

[英]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);">&#160;Re-Subscribe</zoniac:roundrect>&#160;</a>
            </td>
        </tr>                        
        </table>
    </div>
    <div id="loadingDiv" class="cellWhiteBGFont" layoutAlign="top" style="display: block;"><p><img src="<%=ImageMappingManager.getImageName("imgLoading")%>" name = "b1">&nbsp;&nbsp;<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM