当我在 Google Chrome 控制台中输入此脚本时...
<script>
$(document).ready(function() {
$("div").hover(
function() { $("> span", this).show(); },
function() { $("> span", this).hide();
});
});
</script>
...它有效,没有问题。
当我在它之间添加<head></head>
它不起作用。
谁能告诉我为什么?
更新
<script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script type="text/javascript" lang="javascript">
$(document).ready(function()
{
$('div').hover(function()
{
$('> span', this).show();
}, function()
{
$('> span', this).hide();
});
});
</script>
<script type="text/javascript" lang="javascript">
$.getJSON("http://twitter.com/statuses/user_timeline/username.json?callback=?&count=5", function(data) {
$.each(data, function(index, value) {
$('.tweets').append('<div id='+data[index].id+'>'+data[index].text+' <span style="display:none"class="hideTweeterIcons"><a href="https://twitter.com/intent/tweet?in_reply_to='+data[index].id+'"><img src="//si0.twimg.com/images/dev/cms/intents/icons/reply.png"></a><a href="https://twitter.com/intent/retweet?tweet_id='+data[index].id+'"><img src="//si0.twimg.com/images/dev/cms/intents/icons/retweet.png"></a><a href="https://twitter.com/intent/favorite?tweet_id='+data[index].id+'"><img src="https://si0.twimg.com/images/dev/cms/intents/icons/favorite.png"></a></span></div><hr>');
});
});
</script>