如何通过jquery更改backgroundcolor?

Max*_*aun 2 html javascript css jquery jquery-hover

我需要你的帮助:

我有一个网站,我想改变,bg-coler同时盘旋在菜单上(如在rhcp网站上),我已经尝试了jquery但它没有工作..

(只是为了清楚,我不想改变包含我的菜单的div容器的背景颜色它应该是整个身体..-->代码)

谢谢!

码:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>

<script type="text/javascript">
    $('.start').hover(function () {
        $('html').css('background-color', '#676767')
    });
</script>

<?php include_once 'template.php' ?>

<title>Maximilian Braun</title>
</head>

<body>
    <div class="start">
        <h1>
            <a href="actor.php" >Schauspieler</a> - <a href="foto.php">Fotograf</a>
        </h1>
    </div>
    <?php echo footer();?>
</body>
Run Code Online (Sandbox Code Playgroud)

Raj*_*amy 5

尝试将代码包装在document's ready处理程序中,

$(function(){
 $('.start').hover(function(){$('html').css('background-color','#676767') } );
});
Run Code Online (Sandbox Code Playgroud)

由于Jquery无法识别带有类的元素,start而相关元素未被加载.