0

是否可以将工具提示添加到缩略图中以在将鼠标悬停在缩略图上时显示完整标题?还有一种方法可以删除“单击此处”按钮并显示缩略图等吗?工作代码可以在这里找到

<script>
$(document).ready(function(){
    $("button").click(function(){
        $("body").append("<div id = 'data'><ul>.</ul></div>");
        var dataContainer = $("#data ul");
        $.ajax({
            url:'http://gdata.youtube.com/feeds/api/users/googledevelopers/uploads?max-results=50&alt=jsonc&v=2&callback=?',
            dataType: "jsonp",
            timeout: 5000,
            success: function(data){

                     $.each(data.data.items, 
                               function(i, val) {

                                 if (typeof(val.player) !== 'undefined' && typeof(val.title) !== 'undefined') {

                                    dataContainer.append('<div class="d e"><a href='+val.player["default"]+' target="_blank">'+val.title+'</a><br /><img src="'+val.thumbnail.sqDefault+'" width="120" height="90" alt="'+val.title+'"/><br />Views '+val.viewCount+'</div>');
                                 }
                         });
                    }
                });
            });
});
</script>





<body>
<h2>Youtube Most Viewed</h2>
<p>most viewed today</p>
<p><button>Click Here</button></p>

<p><script language="JavaScript">
<!--
date=Date()
document.write(date)
//-->
</script></p>

</body></html>
4

1 回答 1

1

您要更改的内容似乎很简单-无需单击此处即可自动加载,请删除此行:

$("button").click(function(){

和结束线之一:

});

当然,您还需要删除:

<p><button>Click Here</button></p> 

至于标题,请尝试更改此行:

dataContainer.append('<div class="d e"><a href='+val.player["default"]+' target="_blank">'+val.title+'</a><br /><img src="'+val.thumbnail.sqDefault+'" width="120" height="90" alt="'+val.title+'"/><br />Views '+val.viewCount+'</div>');

到这个新行:

dataContainer.append('<div class="d e"><a href='+val.player["default"]+' target="_blank" title="'+val.title+'">'+val.title+'</a><br /><img src="'+val.thumbnail.sqDefault+'" width="120" height="90" alt="'+val.title+'"/><br />Views '+val.viewCount+'</div>');
于 2013-04-06T15:46:53.680 回答