使用jQuery的.html()
或.text()
功能,給id
或class
到將包含如點擊視頻的標題和信息的元素:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('.videos').click(function() {
var value = $(this).attr('title');
$('#myInfo').html(value); //this should do the trick or
$('#myInfo').text(value); //this should do the trick
})
});
</script>
和HTML
<div class = "videos" title = "this is an information">video 1</div>
<div class = "videos" title = "this is an information">video 2</div>
<div class = "videos" title = "this is an information">video 3</div>
<div class = "videos" title = "this is an information">video 4</div>
<div class = "videos" title = "this is an information">video 5</div>
<div id = "myInfo"></div>
像你使用相同的方式出現視頻 – Hushme
,基本上你需要一個jQuery的標籤菜單在網上搜索它,你會得到它 – Hushme