我知道有很多关于这方面的帖子,但没有一个对我有效。我有一个想要用jquery淡入的div。(我原本想让它在用户向下滚动时淡入,但这也不起作用,但如果有人也能帮助我,那就太好了!)
下面是我的代码:
<script src="https://code.jquery.com/jquery-1.10.2.js">
</script>
<script>
$(function() {
$(".twitter-widget").fadeIn(5000);
});
</script>
<style>
#twitter-widget {
position: fixed;
bottom: 15px;
right: 30px;
}
</style>
<div style="text-align: center;" id="twitter-widget">
<div style="Background-color: white; Width: 200px; Height: 100px;" class="content">
<style>
.rhett-link, .chadtronic, .here-now, .htde {
border-radius: 10px;
}`
</style>
<a href="https://twitter.com/averybmiller" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @averybmiller</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<br>
Followed By
<br>
<a href="http://www.twitter.com/rhettandlink">
<img src="https://pbs.twimg.com/profile_images/1617483791/RhettAndLink_Logo_RGB.jpg" height="40px" width="40px" alt="Rhett and Link" class="rhett-link"></a>
<a href="http://www.twitter.com/chadtronic">
<img src="https://pbs.twimg.com/profile_images/642137361124454400/p4Aui6FS.png" height="40px" width="40px" alt="Chadtronic" class="chadtronic"></a>
<a href="http://www.twitter.com/hereandnow">
<img src="https://pbs.twimg.com/profile_images/378800000068124541/9fdeea271f46802d828b3b5a194df006.png" height="40px" width="40px" alt="NPR's Here and Now" class="here-now"></a>
<a href="http://www.twitter.com/htde">
<img src="https://pbs.twimg.com/profile_images/431891488675332096/DDbr4grY.png" height="40px" width="40px" alt="NPR's How to do Everything" class="htde"></a>
<br>
</div>
<div style="background-color: #FF5500; Width: 200px; Height: 2px"></div>
</div>现在fadeIn,或者任何类似jquery的东西都不能工作了。我想不出来。有什么想法吗?
发布于 2015-09-17 10:57:08
<style>必须写在头标签<head></head>里面,而且你的<style>标签在html中有两次是不正确的
您的twitter-widget的id不是类,请将$(".twitter-widget").fadeIn(5000);更改为$("#twitter-widget").fadeIn(5000);
$("#twitter-widget").fadeOut(3000).fadeIn(3000); #twitter-widget {
position: fixed;
bottom: 15px;
right: 30px;
}
.rhett-link, .chadtronic, .here-now, .htde {
border-radius: 10px;
}`<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<div style="text-align:center;" id="twitter-widget">
<div style="Background-color: white; Width: 200px; Height: 100px;" class="content">
<a href="https://twitter.com/averybmiller" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @averybmiller</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<br>
Followed By
<br>
<a href="http://www.twitter.com/rhettandlink">
<img src="https://pbs.twimg.com/profile_images/1617483791/RhettAndLink_Logo_RGB.jpg" height="40px" width="40px" alt="Rhett and Link" class="rhett-link"></a>
<a href="http://www.twitter.com/chadtronic">
<img src="https://pbs.twimg.com/profile_images/642137361124454400/p4Aui6FS.png" height="40px" width="40px" alt="Chadtronic" class="chadtronic"></a>
<a href="http://www.twitter.com/hereandnow">
<img src="https://pbs.twimg.com/profile_images/378800000068124541/9fdeea271f46802d828b3b5a194df006.png" height="40px" width="40px" alt="NPR's Here and Now" class="here-now"></a>
<a href="http://www.twitter.com/htde">
<img src="https://pbs.twimg.com/profile_images/431891488675332096/DDbr4grY.png" height="40px" width="40px" alt="NPR's How to do Everything" class="htde"></a>
<br>
</div>
<div style="background-color: #FF5500; Width: 200px; Height: 2px"></div>
</div>
https://stackoverflow.com/questions/32620950
复制相似问题