我正在做一个项目,它是一个带有缩略图的手风琴,当您单击一个时,手风琴旁边会显示一张图片。到目前为止,我已经设法使用以下代码使其工作:
HTML:
<!--thumbs--->
<a id="1a" href="#"><img src="../../images/thumb/1000.jpg" /></a>
<a id="2a" href="#"><img src="../../images/thumb/1001.jpg" /></a>
<a id="3a" href="#"><img src="../../images/thumb/1002.jpg" /></a>
<a id="4a" href="#"><img src="../../images/thumb/1003.jpg" /></a>
<a id="5a" href="#"><img src="../../images/thumb/1004.jpg" /></a>
<a id="6a" href="#"><img src="../../images/thumb/1005.jpg" /></a>
<!--large photos--->
<img class="hide1" id="1b" src="../../images/fullsize/1000.jpg" />
<img class="hide1" id="2b" src="../../images/fullsize/1001.jpg" />
<img class="hide1" id="3b" src="../../images/fullsize/1002.jpg" />
<img class="hide1" id="4b" src="../../images/fullsize/1003.jpg" />
<img class="hide1" id="5b" src="../../images/fullsize/1004.jpg" />
<img class="hide1" id="6b" src="../../images/fullsize/1005.jpg" />
CSS:
.hide1{
display:none;
}
.show{
display:block !important;
}
和 JS(在 jquery UI 下):
$(function() {
$( "#1a" ).click(function() {
$( ".show" ).toggleClass( "show", 0 );
return false;
});
$( "#1a" ).click(function() {
$( "#1b" ).toggleClass( "show", 0 );
return false;
});
$( "#2a" ).click(function() {
$( ".show" ).toggleClass( "show", 0 );
return false;
});
$( "#2a" ).click(function() {
$( "#2b" ).toggleClass( "show", 0 );
return false;
});
$( "#3a" ).click(function() {
$( ".show" ).toggleClass( "show", 0 );
return false;
});
$( "#3a" ).click(function() {
$( "#3b" ).toggleClass( "show", 0 );
return false;
});
$( "#4a" ).click(function() {
$( ".show" ).toggleClass( "show", 0 );
return false;
});
$( "#4a" ).click(function() {
$( "#4b" ).toggleClass( "show", 0 );
return false;
});
$( "#5a" ).click(function() {
$( ".show" ).toggleClass( "show", 0 );
return false;
});
$( "#5a" ).click(function() {
$( "#5b" ).toggleClass( "show", 0 );
return false;
});
});
有谁知道我可以缩短JS的方法吗?我有 100 多张照片,除非我必须这样做,否则我并不想为所有人都这样做。