如何使用jquery更改导航栏元素背景颜色?

时间:2015-12-08 16:03:54

标签: jquery html

我正在尝试更改元素,它只是不起作用。谁能指出我做错了什么?

$(document).ready(function(){
  $(".navbar").hover(function(){
    $(this).css({'background-color': '#ffffff'});
 });
});

2 个答案:

答案 0 :(得分:2)

Hover function in jquery needs two functions, the handleIn function as the first parameter and the handleOut function.

System.out.println("Second Integer: ");
        while(!scanner.hasNextLong()){
            System.out.println("You entered something bad..  Why do you hurt me?");
            System.out.println("*Calcumatastic dies, and I hope you feel remorseful*");
            try {
                Thread.sleep(4000);
            } catch (InterruptedException f) {
                f.printStackTrace();
            }
            System.exit(0);
        }
        b = scanner.nextLong();
        while (b == 0) {
            System.out.println("Did you even read the instructions??  You cannot divide by zero!");
            System.out.println();
            System.out.println("Second Integer: ");
            b = scanner.nextLong();
        }

答案 1 :(得分:0)

如果你使用萤火虫检查,我想你会应用那个背景。

navbar元素应该有chlid" LI"元素,这样您只需更改

即可为其添加颜色
$(document).ready(function(){
  $(".navbar li").hover(function(){
    $(this).css({'background-color': '#ffffff'});
 });
});