0

I want hide a label according to a dropdown button. I am using a div with JavaScript. My code is:

<div id="ime" name="ime">
    <h3 class="ms-standardheader">
        <label>
            <nobr>IEMI No</nobr>
        </label>
    </h3>
</div>

For hiding through JavaScript,which I am using:

ime.style.display='none';
document.getElementById("ime").style.display='none';
document.getElementsByName("ime").style.display='none';

But this code is not working.

2
  • 2
    document.getElementById("ime").style.display='none'; should work. where you put this code. this should execute after DOM is ready Commented Dec 26, 2011 at 8:48
  • @user633856 : have tried code posted by me??? Commented Dec 26, 2011 at 11:26

3 Answers 3

1

On page load id to this div is not assigned that's way it is not working. Use this after body tag at the end of page.

write this way

<html>
<body>
.
.
.
.
.
</body>
    <script type="text/javascript">
         document.getElementById('ime').style.visibility = 'hidden';
    </script>
</html>
Sign up to request clarification or add additional context in comments.

Comments

0

What if you just use document.getElementById("ime").style.display='none'; without the other two lines (which will not work)?

I expect that the first line will throw an error, because ime is not defined, which will prevent execution of the next two lines.

The third line will not work, because it returns an array of objects, which individually have a style attribute, but not together...

// this would work on the first `ime` tag
document.getElementsByName("ime")[0].style.display='none';

Comments

0

Try this it will work

document.getElementById("ime").style.display='none';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.