简体   繁体   English

使用转场效果更改图像

[英]Change Image with transition effects

I have the following script that changes my image on a timer: 我有以下脚本可以更改计时器上的图像:

var da = setInterval( function() {

    var current_image = document.getElementById('node_picture').src;
    var image_index = current_image.substring(48,49);
    image_index++;

    if (image_index > 4) {
        image_index = 1;
    }

    document.getElementById('node_picture').src="img/node/<?php echo $node_id ?>/" + image_index + ".png";

}, 4000);

I am trying to add a jQuery FadeIn() effect. 我正在尝试添加jQuery FadeIn()效果。 I tried to add 我试图添加

$('node_picture').FadeIn();

but that does not work. 但这不起作用。

Thanks, 谢谢,

Note the case here: 注意这里的情况:

$('node_picture').fadeIn();

http://api.jquery.com/fadeIn/ http://api.jquery.com/fadeIn/

NB: All jQuery methods and properties use camel case with the initial letter in lower case. 注意:所有jQuery方法和属性都使用驼峰式大小写,首字母小写。


When working with selectors, ids should be prefixed with the hash # symbol. 使用选择器时,ID应该以井号#符号为前缀。 I missed this the first time around, your comment made me take another look: 我第一次错过了这个,您的评论让我重新审视了一下:

 $('node_picture').fadeIn(); // wrong $('#node_picture').fadeIn(); // right 

http://api.jquery.com/id-selector/ http://api.jquery.com/id-selector/

-- Unless that's also a typo? -除非那也是错字? ;-) ;-)

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

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