Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Wednesday 26 September 2018

Show/Hide Div on Button Click using HTML, CSS and JavaScript.

code>>


<!--Show/Hide Div on Button Click .-->
<html>
<head>
<style>
        div{
        padding:40px;
        background:yellow;
        }
   </style>
<script type="text/javascript">
function showAndHideDiv(ele) {
var element = document.getElementById(ele);
if (element != null) {
if (element.style.display == "block") {
element.style.display = 'none';
}
else {
element.style.display = 'block';
}
return false;
}
}
</script>
</head>
<body>
<input type="button" value="+/-" onClick="showAndHideDiv('divUniqueId')"/>
        <br><br>
<div id="divUniqueId" style="display:none">
<button>Button 1</button>
                <button>Button 2</button>
</div>
     
</body>

</html>



RUN>>





No comments:

Post a Comment