页面加载完后加载jquery标签:jquery,function,bg,color,ddddddddd,li,eeeeeeeee From: https://blog.51cto.com/u_10028442/5824668
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
/*$(document).ready(function(){
alert("hello");
});*/
$(function(){
alert("hello");
});
</script>
//************************************
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
/*$(document).ready(function(){
});*/
$(function(){
$("li.abc").css("color","red");//li.abc之间不能空格
});
</script>
</head>
<body>
<div id="hello">
<ul>
<li>aaaaaa</li>
<li>bbbbbb</li>
<li class="abc">cccccccccc</li>
<li>ddddddddd</li>
<li>eeeeeeeee</li>
<li>fffffffffff</li>
</ul>
</div>//**************************
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){
$("#hello ul li:even").css("background","#00f").css("color","#fff");
});
</script>
</head>
<body>
<div id="hello">
<ul>
<li>aaaaaa</li>
<li>bbbbbb</li>
<li class="abc">cccccccccc</li>
<li>ddddddddd</li>
<li>eeeeeeeee</li>
<li>fffffffffff</li>
</ul>
</div>
</body>//**************************************************************************
<head>
<title>jquery01.html</title>
<meta http-equiv="keywords" cnotallow="keyword1,keyword2,keyword3">
<meta http-equiv="description" cnotallow="this is my page">
<meta http-equiv="content-type" cnotallow="text/html; charset=UTF-8">
<style type="text/css">
.bg{
background:#f00;
color:#fff;
}
</style>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){
$("li").mouseover(setColor).mouseout(setColor);//检测鼠标放上时是否有bg,没有就加上,鼠标退出时也检测有则此时删掉bg
function setColor(){
$(this).toggleClass("bg");
}
});
</script>
</head>
<body>
<div id="hello">
<ul>
<li>aaaaaa</li>
<li>bbbbbb</li>
<li class="abc">cccccccccc</li>
<li>ddddddddd</li>
<li>eeeeeeeee</li>
<li>fffffffffff</li>
</ul>
</div>
</body>