[英]Hide and show upon onclick function
我的功能運行正常。 但是我似乎無法使用onclick函數隱藏按鈕或顯示新按鈕。
樣品:
var download = document.getElementById('download');
function RemoveDoc(Doc)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","functions/remove.php?Doc="+Doc,true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
download.syle.visibility='hidden';
download.style.display ='none'
document.getElementById("RemoveMsg").innerHTML= xmlhttp.responseText;
}
}
xmlhttp.send();
return false;
}
我的表格
//I tried to add in the download button to be hidden here but still invalid
<input type="submit" id="remove" name="Name" value="Remove" onclick="return RemoveDoc(this.value); document.getElementById('download').style.visibility='hidden'; return false;" />
<input type="submit" id="download" value="download"/> //want to hide this button.
<input type="file" id="reupload"/> //want to show this.
我嘗試過display ='none'對我的下載也無效,因為我的下載在函數成功調用后消失了。 好心提醒
download.style.visibility='hidden';
從通話中刪除回程
onclick="RemoveDoc(this.value); document.getElementById('download').style.visibility='hidden'; return false;"
使用return會使函數調用后的語句無法訪問。
您只能返回一個值。 您有兩個return語句,但它永遠不會到達第二個return語句。
相反,只有一個return語句
<input type="submit" id="remove" name="Name" value="Remove" onclick="RemoveDoc(this.value); document.getElementById('download').style.visibility='hidden'; return false;" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.