•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,801 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,428 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2039 | Replies: 3
![]() |
•
•
Join Date: Jun 2006
Location: UK (Bristol)
Posts: 225
Reputation:
Rep Power: 3
Solved Threads: 1
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.
<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:
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.
Hello, you're through to Steven on the BT Business technical help desk. Could I take your broadband telephone number please?
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 9:25 am.
•
•
Join Date: Jun 2005
Location: Denmark, EU
Posts: 102
Reputation:
Rep Power: 4
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:
<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 Programmer
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- 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



Linear Mode