troubleshooting Question

Change Show/ Hide label on toggle

Avatar of nikhilbansal
nikhilbansal asked on
JavaScriptJScriptAJAX
8 Comments1 Solution392 ViewsLast Modified:
Hi All,

I need this urgently.

I have a Hide option into a <td>

<td>
      <p><font size="5"><strong></strong></font>&nbsp;</p>
      <p><font size="5"><strong>Contents</strong></font> <a onclick="toggle('q1')"
      href="javascript:%20void(0);">[Hide]</a></p>

and I am using the javascript code

function toggle(obj) {

var obj=document.getElementById(obj);


      if (obj.style.display == "block") {
            obj.style.display = "none";
      }
      else {
            obj.style.display = "block";
      }
}

to show/ hide the contents. This so far is working fine

But now I need to change the label "Hide" to "show" when the contents are hidden and "Show" to "Hide" when the cotents are shown.

Please let me know what to do.

Regards

Nikhil

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros