I am really confused. I want to make a <p> tag hidden using javascript, and then, if i detect its running IE, i want to make it visible. I can't even make it hidden though. I have tried

<script type="text/javascript>
document.warning.style[visibility] = 'hidden';

i've tried

<script type="text/javascript>
document.warning.style.visibility = 'hidden';

and i've tried both of these variations with the getElementById('warning') instead of plain old document.warning too. Nothing works. I've even tried setting display to none. What is going on?

Recommended Answers

All 6 Replies

I am really confused. I want to make a <p> tag hidden using javascript, and then, if i detect its running IE, i want to make it visible. I can't even make it hidden though. I have tried

<script type="text/javascript>
document.warning.style[visibility] = 'hidden';

i've tried

<script type="text/javascript>
document.warning.style.visibility = 'hidden';

and i've tried both of these variations with the getElementById('warning') instead of plain old document.warning too. Nothing works. I've even tried setting display to none. What is going on?

try document.warning.style.display = "none";

Try

elementWhatever.style.display = "none";

and

elementWhatever.style.display = "block";

to hide and show the element you are trying to modify.

If
document.name.style.display="none";
does not work, you should check if the object "document.name" and "document.name.style" is effective by using:
alert(document.name);
and
alert(document.name.style);

I tried cmliu2004 said, and i got a warning with the words, undefined in it.

I changed it to a <div> tag surrounding the <p> tag and gave it the ID of warning. Then tried it with alert(document.getElementById('warning')) and it didn't give an alert at all.

Alright, i give up on the styles thing. So i have switched to using an if(isIE) thing that then gives an alert('you are using internet explorer...') thank you for the help anyway!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.