Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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/2/ionic-framework/2.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只切换某些元素_Jquery - Fatal编程技术网

jQuery只切换某些元素

jQuery只切换某些元素,jquery,Jquery,我正在尝试将照片拇指附加到图库中,因为它一次只显示一个大图像,所以我已加载。加载图库后,一切都正常图库显示正确,但我想要的是只显示大图像的拇指。相反,当我尝试切换时,它会切换所有的拇指,所以如果我写 $("#one").slideToggle('medium'); $("#two").slideToggle('medium'); $("#three").slideToggle('medium'); $("#four").slideToggle('medium'); 没关系,大拇指都在那儿 但是

我正在尝试将照片拇指附加到图库中,因为它一次只显示一个大图像,所以我已加载。加载图库后,一切都正常图库显示正确,但我想要的是只显示大图像的拇指。相反,当我尝试切换时,它会切换所有的拇指,所以如果我写

$("#one").slideToggle('medium');
$("#two").slideToggle('medium');
$("#three").slideToggle('medium');
$("#four").slideToggle('medium');
没关系,大拇指都在那儿 但是如果我写

$('div[align=center]:eq(1)').append('<br /><a class="linkone" href="#">Show Gallery</a><div id="one" name="one"></div><div id="two" name="two"></div><div id="three" name="three"></div><div id="four" name="four"></div>');

$("#one").hide();
$("#two").hide();
$("#three").hide();
$("#four").hide();

$(".linkone").click(function(event) {
event.preventDefault();

    var bigimage = $('.forumrow table').find('img:first').attr('src').split(/medium/)[1];  //this is the big image 
    var linkfilter = $('.blockhead a').filter('a[href^="http://www.site.com/showgallery.php?cat="]').attr('href').split(/=/)[1];  //this is the category gallery http://www.site.com/showgallery.php?cat= 123
    var thumb = "http://www.site.com/data/" + linkfilter + "/thumbs" + bigimage;  // this is the thumb if the big image

    if ($('#one .forumrow table img[src="' +thumb+ '"]'))                                
        {
        $("#one").slideToggle('medium');
        } 
或者如果我写信

$('div[align=center]:eq(1)').append('<br /><a class="linkone" href="#">Show Gallery</a><div id="one" name="one"></div><div id="two" name="two"></div><div id="three" name="three"></div><div id="four" name="four"></div>');

$("#one").hide();
$("#two").hide();
$("#three").hide();
$("#four").hide();

$(".linkone").click(function(event) {
event.preventDefault();

    var bigimage = $('.forumrow table').find('img:first').attr('src').split(/medium/)[1];  //this is the big image 
    var linkfilter = $('.blockhead a').filter('a[href^="http://www.site.com/showgallery.php?cat="]').attr('href').split(/=/)[1];  //this is the category gallery http://www.site.com/showgallery.php?cat= 123
    var thumb = "http://www.site.com/data/" + linkfilter + "/thumbs" + bigimage;  // this is the thumb if the big image

    if (bigimage == thumb)                               
        {
        $("#one").slideToggle('medium');
        }

这是错误的,因为它总是显示相同的拇指库,那么,如果有一张大照片,并且单击“显示图库”,我如何管理它?如果我单击“显示图库”,它将仅切换大照片的图库?

当有人单击其中一个选项卡或单击“显示图库”按钮时,您是否试图使它显示更大的图像?避免放置大量隐藏,请使用$id、id2、id3.hide,这只是我喜欢做的一个提示,干净的代码。@ric_bfa-同意。你也可以在这些div中添加一个类,然后可以引用。Kyle,我试图在有人单击show Gallery按钮时显示拇指,因此如果较大的图像是Gallery1的照片,如果我单击ShowGallery1,它只显示Gallery1的拇指,而不是gallery2的拇指,gallery2等等。ric_bfa和RobB,谢谢你,我会这样做的