I have a CV in which I would like to expand and collapse the headings in order
to show and hide the text under the heading. As it is now, I have to write a new function
for every heading in the CV.
Is there a way to get a reference to clicked heading, that is, the <p = id = "element_1" and
then pass it as an argument to the function expandIt(element_1_ref), that is, upon clicking
each header respectively.
Up to now, I will have to write a new "expand/collapse-function" for every new header
I append to my CV. Easy, yes, but programmatically not very well.
The code below works, but I would like to get some tips in order to get it
working according to the above, preferred scenario:
-------------------------------------------------
<A HREF="javascript:expandIt(element_1)" STYLE = "text-decoration:none"><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000">Programmet
för Informatik med systemvetenskap 120 p.</font></A>
<P id = "element_1" STYLE = "display:none">
TEXT....TEXT....TEXT...TEXT
</p>
<script language = "Javascript">
function expandIt(element_1_ref)
{
element_1_ref.style.display = (element_1_ref.style.display == "none" ) ? "" : "none";
}
</script>
----------------------------------------------------
Grateful for tips!
/Perra (Systems developer from Sweden)
to show and hide the text under the heading. As it is now, I have to write a new function
for every heading in the CV.
Is there a way to get a reference to clicked heading, that is, the <p = id = "element_1" and
then pass it as an argument to the function expandIt(element_1_ref), that is, upon clicking
each header respectively.
Up to now, I will have to write a new "expand/collapse-function" for every new header
I append to my CV. Easy, yes, but programmatically not very well.
The code below works, but I would like to get some tips in order to get it
working according to the above, preferred scenario:
-------------------------------------------------
<A HREF="javascript:expandIt(element_1)" STYLE = "text-decoration:none"><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000">Programmet
för Informatik med systemvetenskap 120 p.</font></A>
<P id = "element_1" STYLE = "display:none">
TEXT....TEXT....TEXT...TEXT
</p>
<script language = "Javascript">
function expandIt(element_1_ref)
{
element_1_ref.style.display = (element_1_ref.style.display == "none" ) ? "" : "none";
}
</script>
----------------------------------------------------
Grateful for tips!
/Perra (Systems developer from Sweden)