Hello garevn,
There's a cool little jQuery script that does that nicely here.
One doesn't need jQuery plus a plugin script for that -- there is a much easier way. Have a look at this: http://jsfiddle.net/NXpHe/. And here is the full code in one file:
Code:
<!DOCTYPE HTML>
<html>
<head>
<title>Toggle Display Demo</title>
<script>
function toggleDisplay(id,a)
{
var elaboration = document.getElementById(id);
if (elaboration.style.display == "block")
{
elaboration.style.display = "none";
if(a) a.innerHTML="Read more..."; // won't work with target=_self
}
else
{
elaboration.style.display = "block";
if(a) a.innerHTML = "Fold in...";
}
}
</script>
<style type="text/css">
.toggleLink {
color: red;
text-decoration: underline;
}
.toggleLink:hover {
cursor: pointer;
}
.elaboration {
display: none;
}
</style>
</head>
<body>
<p>Lorem ipsum ... <span class="toggleLink" onclick="toggleDisplay('elaboration_1',this)">Read more...</span> <span class="elaboration" id="elaboration_1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span></p>
</body>
</html>
__________________ Frank
How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.
If you don't mind a bit of complicated structure,
and base the expanding/ collapsing not on a "press",
but on "focus" event, then let's see the following:
You don't really need to do much - it's very simple. Create a hidden div inside your HTML somewhere with the "extra" text, and also create a hidden form field with value="false" (or something of that nature, ie. yes/no). Keep the form field outside of the div. When the link is clicked, send it to a javascript function which will toggle the style settings of that originally hidden div element. In the function, read the value of the hidden text field. If it's "false", set the value to "true" and set the style settings on the div to "display:block". Vice versa.
You don't really need to do much - (....) Vice versa.
What exactly is it that makes you think that the OP would understand one word of what you wrote? S/he doesn't even know whether what s/he wants is possible...
__________________ Frank
How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.
My fault. My intention wasn't to give them the answer but to help them solve it themselves. Knowledge is power, and learning about divs, classes, javascript functions, and form fields is something well worth learning.