javascript按钮显示/隐藏文本已更改

Gho*_*wer 1 javascript button toggle

我想使用java脚本显示和隐藏按钮.

我的问题是按钮应该在页面加载时隐藏,当我在文本框中更改文本时,应该显示按钮.

谢谢.....

Ume*_*til 9

请检查此页面并告知这是否是您想要的.

基本上,您需要使用onchange事件来执行您想要执行的任何操作.

<html>
<head>
<script>
window.onload=function(){
  document.getElementById("button").style.display='none';

}
function showButton(){
  document.getElementById("button").style.display='block';
}
</script>
</head>
<body>
<input type="button" id="button" value="New Button"/>
Change the text in Input Box. Then Button will be show<br/><br/>
<input type="text" id="userText" value="Change the text" onchange="showButton()"/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)