Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript button show/hide on text changed

I want to show and hide a button by using java script.

My problem is that the button should be hide on page load and when I changed the text in text box then button should be show.

thanks.....


1 Answers

pls, Check this page and tell if this is what you wanted.

Basically, you need to use onchange event to do whatever you want to do.

<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>
like image 162
Umesh Patil Avatar answered May 14 '26 10:05

Umesh Patil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!