我试图这样做很长一段时间,但没有成功......见
CSS
.images_list li {
list-style: none;
float: left;
width: 150px;
height: 150px;
margin-right: 10px;
}
.border {
border: 6px solid #D8D8D8;
background: url(upload/check.jpg);
}
.selected {
border: 6px solid green;
}
.hidden {
display:none;
}
span{
position:absolute;
padding-left:119px;
margin-left:-150px;
width:31px;
height:150px;
}
HTML
<div class="images_list">
<li class="border" title="content_1">
<img src="http://imagensface.com.br/imagens/imagens-lindas-imagens-ace558.jpg" width="150" height="150" />
<span>
<img src="http://icons.iconarchive.com/icons/icojam/blue-bits/24/symbol-check-icon.png" />
</span>
</li>
<li class="border" title="content_2">
<img src="http://www.p69.com.br/wp-content/uploads/2013/04/imagens-lindas-6.jpg?0bce15" width="150" height="150" />
<span>
<img src="http://icons.iconarchive.com/icons/icojam/blue-bits/24/symbol-check-icon.png" />
</span>
</li>
</div>
<br><br><br><br><br><br><br><br><br>
<div class="img_info">
<div id="content_1" class="content hidden">content1</div>
<div id="content_2" class="content hidden">content2</div>
</div>
脚本
$('.images_list li').click(function() {
$('.images_list .selected').removeClass('selected');
$(this).toggleClass('selected');
var clicked = $(this).attr('title');
$("#"+clicked).removeClass("hidden").siblings().addClass("hidden");
});
我设法更改边框颜色,但我想将该检查图像放在所选图像的顶部。当没有选择任何内容时,该检查将被隐藏。有什么建议吗?