简体   繁体   中英

Check if DIV is visible or not using javascript

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?

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
   } 
}

Try this solution...

var isVisible = $('#dvData').is(':visible');
alert("dvData is " + isVisible);

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM