Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.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
Javascript 如何在jQuery中链接.html()和.fadeIn()?_Javascript_Jquery - Fatal编程技术网

Javascript 如何在jQuery中链接.html()和.fadeIn()?

Javascript 如何在jQuery中链接.html()和.fadeIn()?,javascript,jquery,Javascript,Jquery,这是我的密码: $('.container-modal-cash').html().fadeIn(1500); 它抛出: 未捕获的TypeError:$(…).html(…).fadeIn不是函数 为什么??我怎样才能修好它 通常我在元素中设置一个内容(使用.html),然后显示它(使用.fadeIn)。怎么了?可以使用.html()设置元素的内容,或者获取元素的内容FadeIn/Out方法在Jquery选择器元素上工作(我的意思是$('.test')) 由提供,当您使用html()设置元素的

这是我的密码:

$('.container-modal-cash').html().fadeIn(1500);
它抛出:

未捕获的TypeError:$(…).html(…).fadeIn不是函数

为什么??我怎样才能修好它

通常我在元素中设置一个内容(使用
.html
),然后显示它(使用
.fadeIn
)。怎么了?

可以使用
.html()
设置元素的内容,或者获取元素的内容
FadeIn/Out
方法在Jquery选择器元素上工作(我的意思是
$('.test')

由提供,当您使用
html()
设置元素的内容时,也可以使用
fadeIn/fadeOut()方法

请参考下面的示例来演示这一点

console.log(“获取内部内容”);
log($('.test').html());
console.log(“设置内部内容”);
$('.test').html('changed content');
//fade在JQuery选择器元素上工作。
$('.test')。衰减(1500);
$('test').fadeIn(1500);
//您可以像这样链接fadeIn/fadeOut方法
$('.test').fadeOut(1500).fadeIn(1500);
//在这样设置html内容时,您还可以链接fadeIn/fadeOut。
$('.test').html(“最终内容”).fadeOut(1500).fadeIn(1500)


内容
只有在
html
函数中设置一些html时,此功能才起作用

$('.container modal cash').html(“测试fadeIn”).fadeIn(1500);
//下面的操作将失败,并出现相同的错误-取消注释下面的代码以进行验证
//$('.container modal cash').html().fadeIn(1500)


html
方法在未提供参数时返回字符串(获取html内容)。当您向
html
提供参数时,它仅提供链接的jQuery元素(该参数仅设置html内容)。您使用的是哪个
jQuery
版本?
$('.test').html("final content").fadeOut(1500).fadeIn(1500);