JavaScript Nav bar mouseenter/mouseleave not working between li elements mouseenter mouseleave not working,jquery mouseenter mouseleave not working,mouseenter

I'mm trying to design a specific type of navbar in javascript/jquery.

I cannot get mouseenter() and mouseleave() to work correctly when the mouse passes between the li objects.

Here is my code. Any ideas?

http://jsfiddle.net/richofwombwell/1v8L0pdz/38/

function inversebuttonon(liId, aId) {
    $(liId).css('background-color', 'white');
    $(aId).css('background-color', 'white');
    $(aId).css('color', '#0086CA');
}

function inversebuttonoff(liId, aId) {
    $(liId).css('background-color', '#0086CA');
    $(aId).css('background-color', '#0086CA');
    $(aId).css('color', 'white');
}

function showselectedmenu(liclass, aclass) {
    $('.menu').css('max-height', '100px');
    $(liclass).css('display', 'inline');
    $(aclass).css('display', 'inline');
}

function dontshowselectedmenu(liclass, aclass) {
    $('.menu').css('max-height', '0px', 'none');
    $(liclass).css('display', 'none');
    $(aclass).css('display', 'none');
}

$('#n-2').mouseenter(function () {
    inversebuttonon('#n-2', '#a2');
    showselectedmenu('.tmenuli', '.tmenua1');
});

$('.menu').mouseleave(function () {
    dontshowselectedmenu('.tmenuli', '.tmenua1');
    inversebuttonoff('#n-2', '#a2');
});

$('#n-3').mouseenter(function () {
    inversebuttonon('#n-3', '#a3');
    showselectedmenu('.tmenuli2', '.tmenua2');
}); 

$('.menu').mouseleave(function () {
    dontshowselectedmenu('.tmenuli2', '.tmenua2');
    inversebuttonoff('#n-3', '#a3');
});
Answer:1

Your script does not work correctly because your html code is invalid (you are nesting DIVs instead of list elements. That forces the browser to correct your code (the way it wants to).

Before you continue scripting, please consider using CSS solution:

 * {
    box-sizing: border-box;
     font-family: sans-serif;
     font-size: 16px;
}
.my_menu {
    height: 66px;
    text-align: center;
    width: 100%;
    overflow:
}
.my_menu ul {
    list-style: none;
}
.my_menu ul li {
    display: inline-block;
}
.my_menu > ul {
    position: relative;
    background: none #0086CA;
}
.my_menu ul a {
    text-decoration: none;
    color: #fff;
    display: inline-block;
}
.my_menu > ul > li > a {
    padding: 15px 20px;
}
.my_menu > ul > li > a:hover,
.my_menu > ul > li a:focus {
    color: #0086CA;
    background: #fff;
}
.my_menu ul ul {
    background: none grey;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    display: none;
}
.my_menu ul li:hover ul {
    display: block;
}
.my_menu ul ul a {
    padding: 5px 10px;
}
.my_menu ul ul a:hover,
.my_menu ul ul a:focus {
    background: none black;
}
<header>
    <nav class="my_menu">
        <ul>
            <li>
                <a target='_blank' href="#">Home</a>
            </li>
            <li>
                <a target='_blank' href="#">menuitem1</a>
                <ul>
                    <li><a target='_blank' href="#">item1</a></li>
                    <li><a target='_blank' href="#">item2</a></li>
                    <li><a target='_blank' href="#">item3</a></li>
                    <li><a target='_blank' href="#">item4</a></li>
                </ul>
            </li>
            <li>
                <a target='_blank' href="#">menuitem2</a>
                <ul>
                    <li><a target='_blank' href="#">item5</a></li>
                    <li><a target='_blank' href="#">item6</a></li>
                    <li><a target='_blank' href="#">item7</a></li>
                    <li><a target='_blank' href="#">item8</a></li>
                </ul>
            </li>
        </ul>
    </nav>
</header>
Answer:2

From an input field I am sending the value as an argument to the function that sets state. I have multiple input fields so would like to use their name (which is equal to their state key) to then use ...

From an input field I am sending the value as an argument to the function that sets state. I have multiple input fields so would like to use their name (which is equal to their state key) to then use ...

Here I am filtering through items: let filter = this.props.data.filter( (item) => { return ( item.fname.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 || item....

Here I am filtering through items: let filter = this.props.data.filter( (item) => { return ( item.fname.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1 || item....

  1. filtering through array javascript
  2. filtering in arrays
  3. filtering in arraylist
  4. filtering using array
  5. filtering arrays in javascript
  6. filtering arrays in python
  7. filtering arrays in typescript
  8. filtering arrays in js
  9. filtering array in angular
  10. filtering array in java
  11. filtering array in php
  12. filtering array in react
  13. filtering array in swift
  14. filtering array in angularjs
  15. filtering array in angular 2
  16. filtering array in jquery
  17. filtering array in vba
  18. filtering array in react js
  19. filtering array in excel
  20. filtering array in matlab

I have a text similar to the text below. It contains a 4 digits number that follows either digit- or whitespace and is followed by either ., ?, -digit or whitespace. I need to match all of the digits ...

I have a text similar to the text below. It contains a 4 digits number that follows either digit- or whitespace and is followed by either ., ?, -digit or whitespace. I need to match all of the digits ...

  1. regex find exact string
  2. regex find exact word
  3. regex find exact word in string
  4. regex find exact number of digits
  5. regex find exact match
  6. regex find exact match python

node.js/express code var express = require('express'), app = express(), port = process.env.PORT || 3000, path = require('path'); app.use('/public', function (req, res) { res.sendfile(...

node.js/express code var express = require('express'), app = express(), port = process.env.PORT || 3000, path = require('path'); app.use('/public', function (req, res) { res.sendfile(...