JavaScript Having to click Twice to get one response having to click twice on everything,having to click mouse

I have made a dropdown that appears on click on a button. Pretty simple, except for how I have to click twice to get the js function to execute. After I click it the first, it appears and disappears like it should - taking only one click. I have no clue why it would require this and have searched for fixes, but none of them seem to work.

Here is my HTML:

<ul class="resources-menu">
    <li>
        <button onclick="res()" id="resbut" onblur="setTimeout('reshide()', 175)">Resources</button>
        <ul id="resblock">
            <li style="padding-bottom: 20px; text-align:center;padding-top:25px">
                <button onclick="dirlnk()">Directory</button>
            </li>
        </ul>        
    </li>
</ul>

CSS:

.resources-menu {
    width:88px;
    float:left;
}
#resbut {
    font-weight:700;
    height:30px;
    text-decoration:underline;
    border-radius:3px;
    border-color: black;
}
ul.resources-menu, ul.resources-menu ul {
    list-style:none;
    margin:0;
    padding:0;
    position: relative;
}
#resblock {
    width: 90px;
    background-color: lightblue;
    display: none;
    position: absolute;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius:15px;
    border-top-right-radius:10px;
    border:solid;
    border-color:black;
}

JavaScript

function res() {
    if (document.getElementById('resblock').style.display == 'none') {
        document.getElementById('resblock').style.display = 'block';
        document.getElementById('resbut').style.background = "lightblue";
        document.getElementById('resbut').style.borderBottomRightRadius = "0px";
        document.getElementById('resbut').style.borderBottomLeftRadius = "0px";
        document.getElementById('resbut').style.borderBottom = "none";
        document.getElementById('resbut').style.textDecoration = "none";
    } else {
        document.getElementById('resblock').style.display = 'none';
        document.getElementById('resbut').style.background = "";
        document.getElementById('resbut').style.borderBottomRightRadius = "";
        document.getElementById('resbut').style.borderBottomLeftRadius = "";
        document.getElementById('resbut').style.borderBottom = "";
        document.getElementById('resbut').style.textDecoration = "";
    }
}
function reshide() {
    document.getElementById('resblock').style.display = 'none';
    document.getElementById('resbut').style.background = "";
    document.getElementById('resbut').style.borderBottomRightRadius = "";
    document.getElementById('resbut').style.borderBottomLeftRadius = "";
    document.getElementById('resbut').style.borderBottom = "";
    document.getElementById('resbut').style.textDecoration = "";
}
function dirlnk() {
    window.location = "/Portal/directory";
}
Answer:1

My application returns the relative positions between two lines and I want draw this lines with Javascript. The line is defined with a director vector, a point and is three dimension. Is there any ...

My application returns the relative positions between two lines and I want draw this lines with Javascript. The line is defined with a director vector, a point and is three dimension. Is there any ...

  1. drawing with elements of art
  2. drawing elements and principles
  3. drawing with elements and principles of art
  4. drawing that have elements of art
  5. drawing in elements

Firstly, sorry for my poor English. I'm learning AngularJS recently and I found that many of AngularJS's concept are very advanced especially the Directive. It's much like the Shadow DOM or Web ...

Firstly, sorry for my poor English. I'm learning AngularJS recently and I found that many of AngularJS's concept are very advanced especially the Directive. It's much like the Shadow DOM or Web ...

I'm using jQuery UI sortable with data-id attributes. I know you can use sortable('serialize') with something like id="row_4" and this does work for me but I need to do it this way. sortable('...

I'm using jQuery UI sortable with data-id attributes. I know you can use sortable('serialize') with something like id="row_4" and this does work for me but I need to do it this way. sortable('...

  1. jquery sortable serialize example
  2. jquery sortable serialize
  3. jquery sortable serialize empty
  4. jquery sortable serialize ajax
  5. jquery sortable serialize not working
  6. jquery sortable serialize multiple lists
  7. jquery sortable serialize to json
  8. jquery sortable serialize table rows
  9. jquery sortable serialize returns empty string
  10. jquery sortable serialize nested list
  11. jquery sortable serialize php
  12. jquery sortable serialize to array
  13. jquery sortable serialize custom attribute
  14. jqueryui sortable serialize
  15. jquery ui serialize
  16. jquery ui serialize not working
  17. jquery ui sortable serialize data attribute
  18. jquery ui sortable serialize example
  19. jquery ui sortable serialize empty
  20. jquery sortable list serialize

As far as I know open() and waitFor() require following steps to be wrapped in then(): casper.click(x('//button[text()="Login"]')); casper.waitForSelector(x('//span[text()="Navigation"]]')); casper....

As far as I know open() and waitFor() require following steps to be wrapped in then(): casper.click(x('//button[text()="Login"]')); casper.waitForSelector(x('//span[text()="Navigation"]]')); casper....