2

我正在尝试制作一个只有 3 张图片的简单 jQuery 画廊,如下图所示。

在此处输入图像描述

我是这样翻译的:

if thumb clicked -> this thumb -> become big
current big -> become thumb

问题是我不知道我翻译的方式似乎正确吗?

谢谢

4

1 回答 1

2

请试试这个:

<html>
<head>
    <title>Simple Gallery</title>
<script src="jquery.js"></script>
<script>
    function ChangeThis(getThumb)
    {
        for(var i=1;i<=3;i++)
        {
            if(getThumb == i)
            {
                $("#bigView").html("<img src='img"+i+"' />");
                $("#thumb"+i).hide();
            }
            else
            {
                $("#thumb"+i).show();
            }
        }
    }
</script>
<style>
#bigView{width:100px;height:100px;}
.thumb{width:30px;height:30px}
</style>
</head>
<body>

<table><tr><td colspan="3">
<div id="bigView"><img src='img1'></div>
</td></tr>
<tr>
<td><div id="thumb1" class="thumb" onclick="ChangeThis(1);" style="display:none;"><img src='img1' /></div></td>
<td><div id="thumb2" class="thumb" onclick="ChangeThis(2);"><img src='img2' /></div></td>
<td><div id="thumb3" class="thumb" onclick="ChangeThis(3);"><img src='img3' /></div></td>
</tr>
</table>
于 2012-10-14T15:20:15.493 回答