Hi this is the simplest JavaScript toggle function to use on click
<script type="text/javascript">
function toggle(element) {
document.getElementById(element).style.display = (document.getElementById(element).style.display == "none") ? "" : "none";
}
// function toggle1(element) {
//document.getElementById(element).style.display = "none";
// }
</script>
<div id="secret" style="display: none;">
<!--content to show on click -->
<div>put your content here which should be show on click</div>
<!--/ontent to show on click -->
</div>
//here is the li where i have use the toggle function
<li><a href="javascript:toggle('secret')" >click here to toggle or hide/show </a></li>
JUST COPY THE WHOLE CODE AND PLACE IN YOUR EDITOR TO GET IT WORK
<script type="text/javascript">
function toggle(element) {
document.getElementById(element).style.display = (document.getElementById(element).style.display == "none") ? "" : "none";
}
// function toggle1(element) {
//document.getElementById(element).style.display = "none";
// }
</script>
<div id="secret" style="display: none;">
<!--content to show on click -->
<div>put your content here which should be show on click</div>
<!--/ontent to show on click -->
</div>
<li><a href="javascript:toggle('secret')" >click here to toggle or hide/show </a></li>
JUST COPY THE WHOLE CODE AND PLACE IN YOUR EDITOR TO GET IT WORK
No comments:
Post a Comment