我想使用 java 脚本显示和隐藏按钮。
我的问题是按钮应该在页面加载时隐藏,当我更改文本框中的文本时按钮应该显示。
谢谢......
最佳答案
请检查此页面并判断这是否是您想要的。
基本上,你需要使用 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>
关于javascript 按钮在文本上显示/隐藏已更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9075440/