在jquery函数回调中应用css属性

在jquery函数回调中应用css属性,jquery,function,Jquery,Function,我试图完成一个回调函数,以减少为三个单独的图像及其各自的文本编写的代码。这些图像有特定的动画在运行,但是我被$e回调卡住了,这是唯一一个没有运行的 出于某种原因,它不需要,但是如果我用“左”来替换动画史诗中的$e,那么动画工作就没有问题了 请问有谁知道函数在接受$e回调时出现问题的原因吗?我尝试了各种各样的带撇号和语音标记的配置,但仍然没有乐趣 谢谢, 丹 函数动画($a、$b、$c、$d、$e、$f、$g){ if($('#urlContainer a').attr('href')==未定义)

我试图完成一个回调函数,以减少为三个单独的图像及其各自的文本编写的代码。这些图像有特定的动画在运行,但是我被$e回调卡住了,这是唯一一个没有运行的

出于某种原因,它不需要,但是如果我用“左”来替换动画史诗中的$e,那么动画工作就没有问题了

请问有谁知道函数在接受$e回调时出现问题的原因吗?我尝试了各种各样的带撇号和语音标记的配置,但仍然没有乐趣

谢谢, 丹

函数动画($a、$b、$c、$d、$e、$f、$g){ if($('#urlContainer a').attr('href')==未定义){ $('#textContainer').hide().html($a).fadeIn(1000); $('#urlContainer').hide().html($b).fadeIn(3000); $('.pictureBox:n个子('+$c++')).animate({opacity:'0'},1000); $('.pictureBox:n个子('+$d++')).animate({$e:$f},1000); $(#homeIcon')。fadeIn(2000年); $('#textContainer a').css({color:$g}); $('footer').hide(); $('.webImg').css({cursor:'default'}); } }; $('.pictureBox:n个子项(1')。单击(函数(){ 动画片($someText1,,'n2',1,'left','32.90%,'red'); }); $('.pictureBox:n个子项(2')。单击(函数(){ 动画史诗($sometext2',1,3,'opacity',0,'seagreen'); }); $('.pictureBox:n子项(3')。单击(函数(){ 动画史诗($sometext3,,'-n+2',3,'right',0,'blue'); });
您可以尝试使用以下代码:

function animatePics($a, $b, $c, $d, $animateOptions, $g) {
    if($('#urlContainer a').attr('href') == undefined) {    
        $('#textContainer').hide().html($a).fadeIn(1000);
        $('#urlContainer').hide().html($b).fadeIn(3000);
        $('.pictureBox:nth-child('+$c+')').animate({opacity: '0'}, 1000);
        $('.pictureBox:nth-child('+$d+')').animate($animateOptions,1000);
        $('#homeIcon').fadeIn(2000);
        $('#textContainer a').css({color: $g});
        $('footer').hide();
        $('.webImg').css({cursor: 'default'});
    }
};

$('.pictureBox:nth-child(1)').click(function() {
    animatePics($someText1,'<a href="http://www.somewebsite1.com" target="_blank">somewebsite1.com</a>','n2',1,{left : '32.90%'},'red');
});

$('.pictureBox:nth-child(2)').click(function() {
    animatePics($sometext2,'<a href="http://www.somewebsite2.com" target="_blank">somewebsite2.com</a>',1,3,{opacity : 0},'seagreen');
});

$('.pictureBox:nth-child(3)').click(function() {
    animatePics($sometext3,'<a href="http://www.somewebsite3.com" target="_blank">somewebsite3.com</a>','-n+2',3,{right : 0},'blue');
});
函数动画史诗($a、$b、$c、$d、$animateOptions、$g){
if($('#urlContainer a').attr('href')==未定义){
$('#textContainer').hide().html($a).fadeIn(1000);
$('#urlContainer').hide().html($b).fadeIn(3000);
$('.pictureBox:n个子('+$c++')).animate({opacity:'0'},1000);
$('.pictureBox:n个子('+$d+')).animate($animateOptions,1000);
$(#homeIcon')。fadeIn(2000年);
$('#textContainer a').css({color:$g});
$('footer').hide();
$('.webImg').css({cursor:'default'});
}
};
$('.pictureBox:n个子项(1')。单击(函数(){
动画片($someText1','n2',1,{left:'32.90%},'red');
});
$('.pictureBox:n个子项(2')。单击(函数(){
动画史诗($sometext2',1,3,{opacity:0},'seagreen');
});
$('.pictureBox:n子项(3')。单击(函数(){
动画史诗($sometext3,,'-n+2',3,{right:0},'blue');
});

在这里,我们删除了
$e,$f
,并传递了JS object holding animation属性。我相信它会根据您的需要工作。

非常好,谢谢。我确实尝试了一些类似的方法,但我从“动画”开始使用了代码,但是我将其全部放在了一个字符串中,这也是我出错的地方!正确…
$。动画制作需要一个JS对象。谢谢……
:)
function animatePics($a, $b, $c, $d, $animateOptions, $g) {
    if($('#urlContainer a').attr('href') == undefined) {    
        $('#textContainer').hide().html($a).fadeIn(1000);
        $('#urlContainer').hide().html($b).fadeIn(3000);
        $('.pictureBox:nth-child('+$c+')').animate({opacity: '0'}, 1000);
        $('.pictureBox:nth-child('+$d+')').animate($animateOptions,1000);
        $('#homeIcon').fadeIn(2000);
        $('#textContainer a').css({color: $g});
        $('footer').hide();
        $('.webImg').css({cursor: 'default'});
    }
};

$('.pictureBox:nth-child(1)').click(function() {
    animatePics($someText1,'<a href="http://www.somewebsite1.com" target="_blank">somewebsite1.com</a>','n2',1,{left : '32.90%'},'red');
});

$('.pictureBox:nth-child(2)').click(function() {
    animatePics($sometext2,'<a href="http://www.somewebsite2.com" target="_blank">somewebsite2.com</a>',1,3,{opacity : 0},'seagreen');
});

$('.pictureBox:nth-child(3)').click(function() {
    animatePics($sometext3,'<a href="http://www.somewebsite3.com" target="_blank">somewebsite3.com</a>','-n+2',3,{right : 0},'blue');
});