我需要将背景颜色属性设置为整个身体,但是我的代码似乎不起作用--我正在学习jquery,但我仍然是个新手。
我使用选择器这个来调用body元素,并向它应用样式。
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery-1.11.1.js">
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
$(this).css("background-color","green");
}
);
</script>
</head>
<body>
<ul id="destinations">
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
<li>Fifth</li>
<li class="six">Sixth</li>
</ul>
<p>This is another parragraph</p>
<p>and this is another more</p>
</body>
</html
>发布于 2014-11-24 04:14:59
*如果您想设置可能不会更改的背景色,则可以使用
$('body').css("background-color","color-name");https://stackoverflow.com/questions/27097507
复制相似问题