toggle node with checkbox

S

student4lifer

Hello,

I currently have a hyperlink to toggle the node, showing and hiding
the list. Could someone show me how to use a checkbox instead of the
hyperlink to do the same thing? Thanks.


I tried the following line but the node's nextSibling becomes
[<u>Fruits:</u>] instead of <div>. Then I tried node.
nextSibling.nextSibling but it didn't work. Please help!

<input type="checkbox" onclick="Toggle(this)" id="Fruits"><u>Fruits:</
u><div>

===========

<html>

<script language="JavaScript">

function Open(node)
{

node.nextSibling.style.display = '';
}

function Close(node)
{

node.nextSibling.style.display = 'none';
}

function Toggle(node)
{

if (node.nextSibling.style.display == 'none')
{
Open(node);
}

else
{
Close(node);
}

}

</script>
<a onclick="Toggle(this)" id="Fruits"><u>Fruits:</u></a><div>
<table>
<tr>
<td>Orange</td>
<td>Apple</td>
<td>Pearl</td>
</tr>
</table>
</div>

</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top