I have the following function in my JavaScript file:
function menu_display(a) {
document.getElementsById("dropmenu2").style.visibility="visible";
}
The problem is the style is not being applied on my object (the function is getting called, I checked that using an alert). In fact, the only suggestions by Microsoft visual web developer for this object are: constructor, toString, valueOf, isProtypeOf and a few more. It is not even suggesting that ‘style’ can be applied. What is the problem?
After fixing getElementsById by replacing with getElementById, the function works fine when I place it in my html file, but if I place it in an external JavaScript file, then the function is getting called (I checked that), but yet again style is not one of the suggestions. This time there are no spelling mistakes.
getElementsById()is not a function of document (or of anything). You’re looking forgetElementById().Check it out on MDN