javascript - document.getElementById not working even if I ve ID present in my css -
javascript - document.getElementById not working even if I ve ID present in my css -
i tried searching didnt valid reply question. "null" when phone call document.getelementbyid("#"+id)
, alerts document not loaded
.
my javascript code
function changedisplay(id) { alert("#"+id); if (!document.getelementbyid("#"+id)) { alert("document not loaded"); } else { if (id == "property_photos") { alert(id); document.getelementbyid("#property_photos").style.display = "block"; document.getelementbyid("#property_details").style.display = "none"; document.getelementbyid("#property_reviews").style.display = "none"; alert(document.getelementbyid(id).style.display); } if (id == "property_details") { alert(id); document.getelementbyid("#property_photos").style.display = "none"; document.getelementbyid("#property_details").style.display = "block"; document.getelementbyid("#property_reviews").style.display = "none"; alert(document.getelementbyid(id).style.display); } if (id == "property_reviews") { alert(id); document.getelementbyid("#property_photos").style.display = "none"; document.getelementbyid("#property_details").style.display = "none"; document.getelementbyid("#property_reviews").style.display = "block"; alert(document.getelementbyid(id).style.display); } } }
the html
<li> <a href="#property_photos" onclick="changedisplay('property_photos')">photos</a> </li> <li> <a href="#property_details" onclick="changedisplay('property_details')">details</a> </li> <li> <a href="#property_reviews" onclick="changedisplay('property_reviews')">reviews</a> </li>
the css
#property_photos { display:none; } #property_details { display:block; } #property_reviews { display:none; }
any help grateful. simple question. got same code work on different page not in page m working on. have called .css file before defining function error persists.
document.getelementbyid()
not need pound (#) symbol.
javascript html css
Comments
Post a Comment