jquery to toggle a label
Posted
by
Juan Almonte
on Stack Overflow
See other posts from Stack Overflow
or by Juan Almonte
Published on 2011-11-30T01:43:31Z
Indexed on
2011/11/30
1:51 UTC
Read the original article
Hit count: 141
How can I get the label to toggle show/hide? Below is my code and currently it is also displaying show. I would like it to toggle from show to hide and from hide back to show. when show is displayed the div will be hidden but when show is clicked the label will switch to hide and the div will be displayed and when hide is clicked the label will go back to show and the div will be hidden
<html>
<head>
<title>jQuery test page</title>
<script type="text/javascript" src="../scripts/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#clickMe").click(function() {
$("#textBox").toggle();
});
});
</script>
</head>
<body>
<label id="clickMe">Show</label>
<br />
<div id="textBox" style="display: none">This text will be toggled</div>
</body>
</html>
© Stack Overflow or respective owner