我是 jQuery 的新手,我不明白为什么图像会显示,但它不会像 jQuery 文档所建议的那样淡入。
<!DOCTYPE HTML>
<html lang='en'>
<head>
<meta charset="UTF-8">
<title>slide show test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<img id="image" alt="slide" style="opacity:0.5;"/>
<script>
var x="tiananmen-square-600.webp";
$("#image").attr('src', x, function() {
$("#image").fadeIn( "slow");
});
</script>
</body>
</html>
请帮忙。
.attr() 不接受第三个参数。
我想你想要这样的东西
$('#image').hide().attr('src', x).fadeIn('slow');
那就是
#image
元素src
属性