Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 缩略图图像在HTML中不会更改库中的主图像_Jquery_Html_Css - Fatal编程技术网

Jquery 缩略图图像在HTML中不会更改库中的主图像

Jquery 缩略图图像在HTML中不会更改库中的主图像,jquery,html,css,Jquery,Html,Css,我试图创建一个带有缩略图的图库,一旦单击主图像,就会更改为缩略图。我目前有缩略图和主图像显示,但当我点击缩略图的主图像没有改变 我使用下面的JQuery更改源文件的结尾。 在“我的图像”文件夹中,我有缩略图(后缀为_thumb)和大图像(后缀为_large)。不知道我哪里出错了,如果你需要更多信息,请询问 HTML头脚本 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2

我试图创建一个带有缩略图的图库,一旦单击主图像,就会更改为缩略图。我目前有缩略图和主图像显示,但当我点击缩略图的主图像没有改变

我使用下面的JQuery更改源文件的结尾。 在“我的图像”文件夹中,我有缩略图(后缀为_thumb)和大图像(后缀为_large)。不知道我哪里出错了,如果你需要更多信息,请询问

HTML头脚本

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

查看你的CSS文件。你是否将jquery代码放在css文件中?是的,jquery在css中,尝试了各种各样的事情,但它不想工作。这不起作用。将jquery放入html或Separate js文件中的内部标记中。永远不要在CSS里面。谢谢你,我不知道我在想什么!
            <div id="panel">
                <img id="largeImage" src="images/foldingbike_large.jpg" />
                <div id="description">First image description</div>
            </div>

            <div id="thumbs">
                <img src="images/foldingbike_thumb.jpg" alt="1st image description" />
                <img src="images/foldingbike2_thumb.jpg" alt="2nd image description" />

             </div>
#thumbs { padding-top: 10px; overflow: hidden; }
#thumbs img, #largeImage {
 border: 1px solid gray;
 padding: 4px;
 background-color: white;
 cursor: pointer;
}
#thumbs img {
 float: left;
 margin-right: 6px;
}
#description {
 background: black;
 color: white;
 position: absolute;
 bottom: 0;
 padding: 10px 20px;
 width: 525px;
 margin: 5px;
}
#panel { position: relative; }

$('#thumbs img').click(function(){
    $('#largeImage').attr('src',$(this).attr('src').replace('thumb','large'));
    $('#description').html($(this).attr('alt'));
});