简体   繁体   English

jQuery-带Php变量的图像淡入

[英]JQuery - Image Fade w/ Php Variables

I have thumbnail images below a larger image. 我在大图下方有缩略图。 The thumbnails, when clicked, need to fade out the current large image, and fade in the thumbnail's large image. 单击缩略图时,需要淡出当前的大图像,并淡入缩略图的大图像。 All the images and theumbnails are being pulled from the database. 所有图像和缩略图均已从数据库中拉出。

Whats the best way to go about doing this? 最好的方法是什么?

$(document).ready(function(){
    $('.thumbnail').live('click', function(){
        var self = this;
        $('#hero img').fadeOut(function(){
            $('#hero img').attr('src', self.src.replace('50x50', '572x362')).fadeIn();
        });
   });
});

the client side, using jQuery, would look something like: 使用jQuery的客户端看起来类似于:

$('.thumbnail').live('click', function(ev){
   ev.preventDefault();
   var self = this;
   $('.largeImage').fadeOut(function(){
      $('.largeImage').attr('src', self.src.replace(/_sm/, '_lg')).fadeIn();
   });
});

Your PHP then just generates the markup with <img class="thumbnail" src="some_img_sm.jpg"> and some div <img class="largeImage"> 然后,您的PHP仅使用<img class="thumbnail" src="some_img_sm.jpg">和一些div <img class="largeImage">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM