Сообщение от RodgerFox
|
как заставить первым элементам в каждом списке быть активными с самого начала
|
Ну косинус же! (с)
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="tmp.css" />
-->
<style type="text/css">
.on {
color: red;
background-color: yellow;
}
</style>
<script type="text/javascript">
$(document).ready(function (){
$(':radio').click(function (){
var o=$(this);
$(this).parents('ul').find('.on').removeClass('on');
$(this.parentNode).addClass('on');
});
});
</script>
</head>
<body>
<article>
<ul>
<li for="id_1" class='on'><input type="radio" name='grp1' checked /><label> .. </label></li>
<li for="id_2"><input type="radio" name='grp1' /><label> .. </label></li>
</ul>
</article>
<article>
<ul>
<li for="id_53" class='on'><input type="radio" name='grp2' checked /><label> .. </label></li>
<li for="id_54"><input type="radio" name='grp2' /><label> .. </label></li>
</ul>
</article>
<article>
<ul>
<li for="id_86" class='on'><input type="radio" name='grp3' checked /><label> .. </label></li>
<li for="id_87"><input type="radio" name='grp3' /><label> .. </label></li>
</ul>
</article>
</body>
</html>