我正在编写一个小页面,允许人们创建各种YouTube视频的列表(带有自定义标题和描述),并让他们在同一页的iFrame中显示视频。所有这些都已经实现,并且运行良好。
但最重要的是,我也想让视频的标题显示在一个div (#tv-标题),但这部分是我似乎无法弄清楚。
理想情况下,我希望在div中显示-tag的title属性中提供的内容。
有人能帮我吗?
现在我的代码就是这样看的:
<div id="tv-title">This is where the title-attribute content should go</div>
<iframe name="tv-frame" id="tv-frame" src="#" frameborder="0" allowfullscreen></iframe>
<ul id="tv-list">
<li>
<a href="#" target="tv-frame" title="Title 1"><span class="li-title">Title 1</span><span class="li-description">Description 1</span></a>
<a href="#" target="tv-frame" title="Title 2"><span class="li-title">Title 2</span><span class="li-description">Description 2</span></a>
</li>
</ul>提前感谢
发布于 2013-07-25 11:31:37
你可以试试这个-
$('a[target="tv-frame"]').on('click',function(e){
$('#tv-title').text(this.title);
});发布于 2013-07-25 11:36:51
你可以试试这个
$("a").on('click',function(){
var title=$(this).attr("title");
$("#tv-title").text(title);
});发布于 2013-07-25 11:38:29
工作演示tushar/6DDu6/
$('a[target="tv-frame"]').click(function(){
$('#tv-title').text($(this).attr('title'));
});https://stackoverflow.com/questions/17856720
复制相似问题