【发布时间】:2015-04-29 13:33:18
【问题描述】:
我希望有一个复选框(足球),当
未选中:
- 显示一个 DIV (FootballChoice),其中包含随鼠标悬停而变化的复选框的标签图像
已检查:
- 隐藏 DIV (FootballChoice)
- 显示一个隐藏的 DIV (FootballChecked),其中包含一个备用标签图像
- 显示另一个隐藏的 DIV (FootballTeams)。
再次取消选中时,需要恢复到原来的状态。
或者,如果有人知道如何在选中时将标签图像更改为与此处鼠标悬停元素中指定的相同,那也是一个有用的替代方法?
提前谢谢你。
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input[type="checkbox"]').click(function(){
if($(this).attr("value")=="FootballTeams"){
$(".FootballTeams").toggle();
$(".FootballChecked").toggle();
$(".FootballChoice").toggle();
}
});
});
</script>
.FootballChecked {
display: none;
}
.FootballChoice {
display: show;
}
.sport {
display: none;
border: 1px dashed #FF3333;
margin: 10px;
padding: 10px;
background: #003366;
}
<input id="Football" type="checkbox" value="FootballTeams">
<div class="FootballChoice">
<label for="Football" class="FootballChoice">
<img src="http://web.static.nowtv.com/email-marketing/assets/structure/SPORTSPREF_FOOTBALL_100x130.png" onmouseover="this.src='http://web.static.nowtv.com/email-marketing/assets/structure/SPORTSPREF_FOOTBALL_NAME_100x130.png';" onmouseout="this.src='http://web.static.nowtv.com/email-marketing/assets/structure/SPORTSPREF_FOOTBALL_100x130.png';" alt="Football" title="Football">
</label>
</div>
<div class="FootballChecked">
<label for="Football">
<img src="http://web.static.nowtv.com/email-marketing/assets/structure/SPORTSPREF_FOOTBALL_NAME_100x130.png" alt="Football" title="Football">
</label>
</div>
<div class="sport FootballTeams">
Football Teams here
</div>
【问题讨论】:
-
我很惊讶地看到
display: show;。有没有类似的属性可以展示?
标签: javascript html css checkbox