![]() |
|
#1
|
|||
|
|||
|
I'm trying to create a drop-down button...
[code:92t9638hus]<div class="drop_button"> <div class="button"> <input type="button" class="default" value="Create New"><input type="button" class="options" onclick="this.parentNode.parentNode.getElementsByT agName('ul')[0].style.display= (this.parentNode.parentNode.getElementsByTagName(' ul')[0].style.display=='') ? 'none' : '';" onblur="setTimeout('document.getElementById(\'yyy\ ').style.display=\'none\';', 200)"> </div> <ul id="yyy" class="dropdown" style="display:none">[*]abc[*]defgh[/list]</div> <style> .drop_button { float:left; margin:0 2px; } .drop_button .button input { background-color:#99c1bb; border-left: 1px solid #eeeeee; border-top: 1px solid #eeeeee; border-right: 1px solid #000000; border-bottom: 1px solid #000000; font-family: Tahoma, Verdana, Arial; font-size: 12px; } .drop_button .button input.options { width:12px; } .drop_button .button input.options { width:15px; padding: 0px; margin: 0px; background-image: url(downarrow.gif); background-repeat: no-repeat; background-position: center; } .drop_button ul.dropdown { padding:0px; margin:0px; width:130px; list-style-type: none; position:absolute; background-color: #cccccc; } .drop_button ul.dropdown li { border: 1px solid black; padding:0px; margin:0px; } .drop_button ul.dropdown li a { display:block; padding:2px; margin:0px; text-decoration: none; color: #000000; font-family: Tahoma, Verdana, Arial; font-size: 12px; } .drop_button ul.dropdown li a:hover { background-color: #00ffff; } * html .drop_button ul.dropdown li a { width:150px; w\idth:129px; } </style> [/code:92t9638hus] There are two issues with this... The first one was that the onblur event happened before the link could be processed...so I added a setTimeout for 200 milliseconds to allow the link to be processed. It works fine, but I don't want to use an arbitrary ID "yyy" to grab the object. I would prefer not doing this...in fact I would prefer not doing the setTimeout at all. The point of this piece of code is to be self-contained...no external code, just drop it in and it works. So no initialization functions or whatnot. Is there any way of doing this? |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|