2010-04-09 51 views
0

我有以下脚本改变一个计时器我的形象:更改图片过渡效果

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); 

我想添加一个jQuery淡入()的作用。我试图添加

$('node_picture').FadeIn(); 

但这不起作用。

感谢,

回答

3

注意这里的情况:

$('node_picture').fadeIn(); 

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

注:所有的jQuery的方法和属性,使用骆驼情况下为小写的首字母。


当使用选择器时,ids应该以散列 #符号为前缀。我周围错过了这个第一次,您的评论让我再看一看:

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

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

- 除非这也是一个错字? ;-)

+0

我错误地在原来的文章中,我在代码中使用小写,这不是问题。 – Goro 2010-04-09 22:05:56

+1

@Goro:你是不是还输错了缺少的'#'符号?看到我更新的答案。 – 2010-04-09 22:24:55

+0

是的,我确实想念那个。但是,它似乎也没有与之合作。 – Goro 2010-04-09 22:50:10