| | |
Javascript + HTML DOM problem
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hello everyone. I am trying to write a drop down menu Javascript and have run into a little problem. I need to change the (opacity=0) value inside this custom style:
The obvious approach would seem to be:
and fill out the contents of the .menu attribute with the changed opacity value. However, when I try this nothing gets changed and my menu remains invisible :mad: . I have read some tutorials on w3schools about this but they don't go into the specifics of changing custom styles with DOM. Any help with this little snag would be appriciated.
Steven.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<style id="menu_style" type="text/css"><!--.menu {z-index: 3; filter: alpha(opacity=0); position: absolute; left: 200px; top: 100px; width: 180px; height: 210px; background-color: #0000FF}
The obvious approach would seem to be:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
document.getElementById("menu_style").menu="....
and fill out the contents of the .menu attribute with the changed opacity value. However, when I try this nothing gets changed and my menu remains invisible :mad: . I have read some tutorials on w3schools about this but they don't go into the specifics of changing custom styles with DOM. Any help with this little snag would be appriciated.
Steven.
The one question you should not ask when teaching a new language structure is "Do you understand?". Do you understand?
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
I believe "CSS" filters are an IE-only, non-standard, non-compliant "thing".
Regardless, you cannot change the CSS declaration itself. CSS Stylesheets are not part of the DOM. You can, however, use JavaScript to change the style of an individual HTML element. Since styles cascade, the element will use the original class/id declaration except when specifically overriden by an inline style.
So, rather than trying to get the "CSS element", get a handle to the actual styled HTML element, and interact with it.
Regardless, you cannot change the CSS declaration itself. CSS Stylesheets are not part of the DOM. You can, however, use JavaScript to change the style of an individual HTML element. Since styles cascade, the element will use the original class/id declaration except when specifically overriden by an inline style.
So, rather than trying to get the "CSS element", get a handle to the actual styled HTML element, and interact with it.
Last edited by tgreer; Oct 3rd, 2006 at 10:25 am.
•
•
Join Date: Jun 2005
Posts: 107
Reputation:
Solved Threads: 3
CSS "filters" are IE-only.
Use the "visibility" att.
Something along the lines of this should work:
Use the "visibility" att.
Something along the lines of this should work:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<style> #dropdownmenu { position: absolute; top: 20px; left: 20px; visibility : hidden; } </style> <javascript> function showDropDown() { document.getElementById("dropdownmenu").style.visibility = "visible"; } </javascript> <a onMouseOver="showDropDown()">show me now</a> <div id="dropdownmenu"> item item item </div>
Web Developer
When something seems too good to be true...it usually is
When something seems too good to be true...it usually is
![]() |
Similar Threads
- I hate Firefox! (JavaScript / DHTML / AJAX)
- Vey hard problem.. no idea how to solve ??? (JavaScript / DHTML / AJAX)
- Flash/Javascript/HTML code for gallery page (Web Development Job Offers)
- Help modify some JavaScript/HTML (JavaScript / DHTML / AJAX)
- New Language combines: Asynchronous JavaScript+CSS+DOM+XMLHttpRequest (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How to pass the values of javascript in perl
- Next Thread: Drop Down Menu Height
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor decimal dependent design disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl listbox math media microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player post problem progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






