javascript if statement checking if div is visible not working -
i cannot life of me figure out why if statement not working.
the retrieveinfo function passed event
, code
, , target div
seen here:
onmouseover="return retreiveinfo(event, 'm003', 'target')"
i must utilize code provided much possible school assignment.
function retreiveinfo(e, moviecode, div) { if(e.pagex) { this.x = e.pagex; } else { this.x = e.clientx; } if(e.pagey) { this.y = e.pagey; } else { this.y = e.clienty; } div = document.getelementbyid(div); if(div.style.visibility == "visible") { console.log("more good"); } else if(div.style.visibility == "hidden"){ console.log("hidden"); } }
checking "style" object works if html markup included "style" attribute, or if it's been modified elsewhere code. if there's css making object's "visibility" property "hidden", won't able tell method.
there other ways objects not visible well:
display: none
position: absolute; left: -10000px;
etc. element can within element that's hidden well. thus, determining whether particular element in dom visible not simple task :-)
now, if code elsewhere like:
document.getelementbyid(whatever).style.visibility = "hidden";
then code should work fine.
javascript
No comments:
Post a Comment