87,993
社区成员
发帖
与我相关
我的任务
分享<div class="box">
<ul class="box-list clearfix">
<li>
<div class="index">01</div>
<div class="img"><img src="../static/imagess/pademo_grey.png" th:src="@{/imagess/pademo_grey.png}"></div>
<label><input type="checkbox" name="station_name" id="01" value="七莘路站" />七莘路站</label>
</li>
<li>
<div class="index">02</div>
<div class="img"><img src="../static/imagess/pademo_grey.png" th:src="@{/imagess/pademo_grey.png}"></div>
<label><input type="checkbox" name="station_name" id="02" value="虹莘路站" />虹莘路站</label>
</li>
<li>
<div class="index">03</div>
<div class="img"><img id="03" src="../static/imagess/pademo_grey.png" th:src="@{/imagess/pademo_grey.png}"></div>
<label><input type="checkbox" name="station_name" id="03" value="03" />顾戴路站</label>
</li>
<li>
<div class="index">04</div>
<div class="img"><img src="../static/imagess/pademo_grey.png" th:src="@{/imagess/pademo_grey.png}"></div>
<label><input type="checkbox" name="station_name" id="04" value="东兰路站" />东兰路站</label>
</li></div>
$('input[name="station_name"]').click(function() {
if (this.checked) {
$(this).closest('.box').find('img').attr('src', '../static/imagess/pademo_blue.png');
} else {
alert("hello");
}
});
$('input[name="station_name"]').click(function() {
if (this.checked) {
$(this).parent().parent().find('img').attr('src', '../static/imagess/pademo_blue.png');
} else {
alert("hello");
}
});

$('input[name="station_name"]').click(function() {
if (this.checked) {
$(this).siblings('.box').find('img').attr('src', '../static/imagess/pademo_blue.png');
} else {
alert("hello");
}
}); 这个是我的代码 , 未选中时就回到之前的图片 , 状态是从后台获取 , 换图片这里我改了很多次都有问题 , 麻烦大神帮我看看