1

私は、人々がさまざまな YouTube ビデオのリスト (カスタム タイトルと説明付き) を作成し、同じページの iFrame にビデオを表示できるようにする小さなページに取り組んでいます。これらはすべてすでに実装されており、正常に動作しています。

その上で、動画のタイトルをdiv(#tv-title)で表示したいのですが、この部分がわかりません。

-tag の title 属性で提供されるコンテンツを div に表示するのが理想的です。

これで私を助けることができる人はいますか?

これは私のコードが現時点でどのように見えるかです:

<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>

前もって感謝します

4

3 に答える 3

1

あなたはこれを試すことができます -

$('a[target="tv-frame"]').on('click',function(e){
    $('#tv-title').text(this.title);
});
于 2013-07-25T11:31:37.573 に答える
0

ワーキングデモhttp://jsfiddle.net/cse_tushar/6DDu6/

$('a[target="tv-frame"]').click(function(){
    $('#tv-title').text($(this).attr('title'));
});
于 2013-07-25T11:38:29.650 に答える