Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two button hide and show when i click on hide div will be hide and when i click on show div will be display but when i try this code and click on hide button div can not hide ...

how to solve this

What I have tried:

<head>
<title></title>
<meta charset="utf-8" />
<script src="jquery-2.2.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("btnhide").click(function () {
$("#dvmain").hide();
});
$("btnshow").click(function () {
$("#dvmain").show();
});

});


</script>
</head>
<body>
<input type="button" id="btnshow" value="show" />
<input type="button" id="btnhide" value="hide" />

</body>
Posted
Updated 10-Mar-16 0:41am
v2
Comments
Gokulprasad05 5-Mar-16 7:37am    
remove title and meta charset. and Give correct script path

You are using id as selector, e.g.
id="btnshow"
, so in the jquery script, it should be referred to as
$("#btnshow")

Learn more: jQuery #id Selector[^]
 
Share this answer
 
<html>
<head>

<style>
#header {
background-color:red;
padding:5px;
height:300px;
width:100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#btnhide").click(function(){
$("#header").hide();
});
});
$(document).ready(function(){
$("#btnshow").click(function(){
$("#header").show();
});
});
</script>
</head>
<body>

<input type="button" id="btnhide" value="hide" />
<input type="button" id="btnshow" value="show" />

</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900