2024-09-30 00:00:23
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>Select Tester</title>
<style>
ul li.kk{background: red;}
ul li.dd{background: green;}
</style>
<script src="jquery-1.8.0.min.js"></script>
<script type="text/javascript" >
jQuery(function($){
$('ul li.kk').click(function(){
$(this).nextUntil('ul li.kk').css('background-color','orange');
});
});
</script>
</head>
<body>
<ul>
<li class="kk">1</li>
<li class="dd">0</li>
<li class="dd">0</li>
<li class="dd">0</li>
<li class="kk">2</li>
<li class="dd">0</li>
<li class="dd">0</li>
<li class="dd">0</li>
</ul>
</body>
</html>
如果都是div呢?
1
0
2
0
$('.kk').click(function(){
$(this).nextUntil('.kk').css('background-color','orange');
});