It is Javascript code for HTML files such that if you click on certain text, other text appears or disappears, toggling from its current state. As modified by Manu Agrawal in the comments and by me (he had a typo I think), what you do is put the following just after the <body> command in the HTML file (maybe anywhere after it would do)
<!-- Arvind Satyanarayan script added by John Smith on Oct XX, 20XX. -->
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
Then, to display "(Click here to read more.)" and have "Here is where all the rest of the post would go." display when "(Click here to read more.)" is clicked (or concealed when it is clicked again), insert
<a href="#" onclick="toggle_visibility('07oct2');">(Click here to read more.)</a>
<div id="07oct2" style='display:none'>
Here is where all the rest of the post would go.
</div>
You can insert as many of these as you like in one file, with just one insertion of the script, so long as you give distinct titles, not "07oct2" to the second and later concealed sections.
2 Comments:
Thank you for re-interpreting the instructions. Your walkthrough made this a lot clearer for me and I was finally able to get this javascript to work for me.
Thank you!
Thanks for making this simple enough for a beginner like me. I'm just getting my feet wet with javascript and I managed to make this work.
Post a Comment
Links to this post:
Create a Link
<< Home