0

I have two <div> in server side web service page. If I click the first div, the first div should be hidden and second div should be visible. How to hide the first div and show second div using onclick div in server side web service page.

Javascript

function switchVisible() {
    if (document.getElementById('hidediv')) {
        if (document.getElementById('hidediv').style.display == 'none') {
            document.getElementById('showdiv').style.display = 'block';
            document.getElementById('showdiv').style.display = 'none';
        }
     else {
            document.getElementById('hidediv').style.display = 'none';
            document.getElementById('showdiv').style.display = 'block';
          }
     }
}

HTML

sbBuilder.Append("<div href='#' id='" + "' onclick=" + '"' + "javascript:return ")                
sbBuilder.Append("</div>");
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

just replace the first line of if condition with if (document.getElementById('hidediv').style.display!== 'none')

Ravi Patil
  • 127
  • 2
  • 16