tags:

views:

53

answers:

2

Hi,

I have an input text field which has

style: "visibility: visible"

or

style: "visibility: hidden"

What is the easiest way to find out if it is visible or not ?

Suppose the input text field is E. What should be the condition here:

if <something with E> {
    alert("The text filed is visible !!");
}

?

Thanks in advance !

+6  A: 

Like this:

if(element.style.visibility == "visible") {
    alert("The text filed is visible !!");
}

If you also need code to get the element, here's an example by the id attribute:

var element = document.getElementById("myInputID");
if(element.style.visibility == "visible") {
    alert("The text filed is visible !!");
}

The above code would find an element like this (note IDs should be unique):

<input type="text" id="myInputID" />
Nick Craver
+1  A: 
if(document.getElementByid(YOUR_OBJECT_ID_HERE).style.visbility == 'hidden')
{
   alert('Hidden');
}

This should work.

Kevin