<head>
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("div").click(function () {
$("#ratings td").html("<img src='images/22.jpg'/>").mouseover(function () {
$(this).html("<img src='images/11.jpg'/>");
$(this).siblings().html("<img src='images/11.jpg'/>");
$(this).nextAll().html("<img src='images/22.jpg'/>"); });
$("#ratings td").mouseout(function () {
$("#ratings td").html("<img src='images/22.jpg'/>");
});
});
</script>
</head>
<body>
<div>aa</div>
<div>bb</div>
<div><a href="###">百度</a></div>
<table id="ratings" style="margin-top:50px;">
<tr><td></td><td></td><td></td><td></td><tr>
</table>
</body>
执行以上代码效果不能够正常显示,把执行mouseout这段去掉后就可以正常显示了,请问这个怎么解决?
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("div").click(function () {
$("#ratings td").html("<img src='images/22.jpg'/>").mouseover(function () {
$(this).html("<img src='images/11.jpg'/>");
$(this).siblings().html("<img src='images/11.jpg'/>");
$(this).nextAll().html("<img src='images/22.jpg'/>"); });
$("#ratings td").mouseout(function () {
$("#ratings td").html("<img src='images/22.jpg'/>");
});
});
</script>
</head>
<body>
<div>aa</div>
<div>bb</div>
<div><a href="###">百度</a></div>
<table id="ratings" style="margin-top:50px;">
<tr><td></td><td></td><td></td><td></td><tr>
</table>
</body>
执行以上代码效果不能够正常显示,把执行mouseout这段去掉后就可以正常显示了,请问这个怎么解决?
$(function () {
$("div").click(function () {
$("#ratings td").html("<img src='images/22.jpg'/>").mouseover(function () {
$(this).html("<img src='images/11.jpg'/>");
$(this).siblings().html("<img src='images/11.jpg'/>");
$(this).nextAll().html("<img src='images/22.jpg'/>"); });
$("#ratings td").mouseout(function () {
$("#ratings td").html("<img src='images/22.jpg'/>");
});
});
});
</script>
少了
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="jquery-1.8.0.js"></script>
</head>
<body>
<div>aa</div>
<div>bb</div>
<div><a href="###">百度</a></div>
<table id="ratings" style="margin-top:50px;">
<tr><td></td><td></td><td></td><td></td><tr>
</table>
</body>
<script type="text/javascript">
$(function(){
$("div").click(function () {
$("#ratings td").html("22").mouseover(function () {
$(this).html("11");
$(this).siblings().html("11");
$(this).nextAll().html("22"); });
$("#ratings td").mouseout(function () {
$("#ratings td").html("22");
});
});
});
</script>
</html>
$("div").click(function () {
$("#ratings td").html("<img src='images/22.jpg'/>").mouseover(function () {
$(this).html("<img src='images/11.jpg'/>");
$(this).siblings().html("<img src='images/11.jpg'/>");
$(this).nextAll().html("<img src='images/22.jpg'/>"); });
$("#ratings td").mouseout(function () {
$("#ratings td").html("<img src='images/22.jpg'/>");
});
});
这个是你的源码
$("div").click(function (){ 是不是 没有闭合
如果加上就可以了 我测试过了 至于你是不是比较乱 这个是你需要美化css啊