-1

heyy,

i want to create some hover background link when mouseover in jquery !!!

when the mouse over on " .nav Menu nav a ", I add addclass " .hover " and when mouse out removeClass " .hover "

more info on my fiddle -> demo JS FIDDLE

HTML : > >

            <a href="inc/about/" class="Load frame" id="html" data-html="about">
             <div class="hover"></div> about
            </a>

            <a href="inc/porject/" class="Load frame" id="html" data-html="project">
              <div class="hover"></div> project
            </a>

            <a href="inc/story/" class="Load frame" id="html" data-html="story">
             <div class="hover"></div> story
            </a>

            <a href="inc/contact/" class="Load frame" id="html" data-html="contact">
              <div class="hover"></div> contact
            </a>

CSS :

.navMenu nav {

      width: 100%; height: auto;
      list-style-type: none; margin: auto auto;
      text-align: center;

    }


.navMenu a {

      height: 4em; width: 100%; 
      text-decoration: none; text-transform: uppercase;
      text-align: center; display: block;
      line-height: 4em; font-weight: normal;
      font-size: 1em; color: rgba(238,79,87,1); 
      position: relative; z-index: 100;

}

.hover{

    /* add background, width, height, ect... */

}

JS:

function hoverLi(){

        $(".navMenu a").hover(function(){

          $(this).stop(true, true).addClass("hover");

        },function(){

          $(this).removeClass("hover");


        });


      }

thanks a lot

3 Answers3

0

Here is JSFiddle

http://jsfiddle.net/t6d4hvkg/4/

use css selector :hover

It's a pseudoclass

update your CSS:

.navMenu nav {

  width: 100%; height: auto;
  list-style-type: none; margin: auto auto;
  text-align: center;

}


.navMenu a {

  height: 4em; width: 100%; 
  text-decoration: none; text-transform: uppercase;
  text-align: center; display: block;
  line-height: 4em; font-weight: normal;
  font-size: 1em; color: rgba(238,79,87,1); 
  position: relative; z-index: 100;

}

.navMenu nav:hover{

background:#000000;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
color:white;

}
Kristian
  • 2,456
  • 8
  • 23
  • 23
0

Just in case you insist to use jQuery then you just need to remove your function and leave just this part:

$(".navMenu nav a").hover(function(){
    $(this).addClass("hover");
},function(){
    $(this).removeClass("hover");
});

Check out this DEMO..

Bla...
  • 7,228
  • 7
  • 27
  • 46
0

I guess you need to add a background color to your hover class like so:

.hover{
  background-color:#eee; 

}

and then call document.ready function, passing your HoverLi function to it.

Mekicha
  • 811
  • 9
  • 21