簡體   English   中英

當我單擊文本框時如何清除JavaScript中的成功消息

[英]When I click text box how to clear Successful message in javascript

當我使用“提交”按鈕提交數據時,我收到“已成功插入”消息,當我單擊文本框時,我需要清除此消息,如何清除此消息。

謝謝

為了適當地幫助您,您應該發布一些自己編寫的實際代碼。

有了您提供的內容,我可以假設您可以執行以下操作:

 window.onload = function() { var elArr = document.querySelectorAll('input[type=text]'); for (var i = 0, len = elArr.length; i < len; i++) { elArr[i].addEventListener('focus', clearText); } } function clearText() { document.getElementById('alert').style.display = 'none'; } 
 span { color: red; display: block; } 
 <input id="textbox" type="text"> <input id="textbox2" type="text"> <input id="textbox3" type="text"> <input id="textbox4" type="text"> <input id="textbox5" type="text"> <span id="alert">Success!</span> 

嘗試這個

<input id="textbox1" type="text"  onmouseenter="clearSuccessLabel()" >
<input id="textbox2" type="text"  onmouseenter="clearSuccessLabel()" >
<input id="textbox3" type="text"  onmouseenter="clearSuccessLabel()" >
<input id="textbox4" type="text"  onmouseenter="clearSuccessLabel()" >
<input id="textbox5" type="text"  onmouseenter="clearSuccessLabel()" >
<span id="alert">Success!</span>

function clearSuccessLabel() 
{
  document.getElementById('alert').innerHTML = "";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM