1

I have a div name uploadBiodata_manual_+(count).within that div i have a file type input with id 'file_uploadBiodata_manual_+(count)'.Here how to check div is visible or not.?and if div is visible how to check the file type input has file?

5
  • stackoverflow.com/questions/10406094/… it will help you.... its with jQuery Commented Aug 6, 2014 at 9:46
  • 1
    Guys, he asked for pure javascript... So he's not using jQuery. Commented Aug 6, 2014 at 9:53
  • i am using display: none; Commented Aug 6, 2014 at 10:00
  • Well then just do document.getElementById("myElement").style["display"] == "none"; Commented Aug 6, 2014 at 10:04
  • yes it works.but how i wil get whether the file type has file? Commented Aug 6, 2014 at 10:13

2 Answers 2

6

you could just check for div display property along with input file type's value property, like:

if(document.getElementById("your_div_id").style.display != "none") {
    //its visible
   //check if input fie type has file selected
   if(document.getElementById("your_file_input_id").value != "") {
       //its has file selected
   } 
}
Sign up to request clarification or add additional context in comments.

1 Comment

What if the parent is the one that has the visibility none
3

check clientHeight. It will be zero for invisible elements

 isVisible=function(elemID){
    var e=document.getElementById(elemID);
    if(!e) return false;            //Not exisiting
    if (e.clientHeight) return true;        //Height of invisible components are zero
    return false
}

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.