如何拍摄并将其置于特定的DIV中

时间:2015-06-05 18:15:49

标签: javascript jquery html

我是jquery的新手,我正在做一个滑块。

我有:

<ul>
    <li> <img src="image.jpg"><p>description of the current image</p></li>
    <li> <img src="image.jpg"><p>description of the current image</p></li>
    <li> <img src="image.jpg"><p>description of the current image</p></li>
    <li> <img src="image.jpg"><p>description of the current image</p></li>
</ul>

我需要做的是当我点击特定的<li>元素时,它将显示在带有内容的灯箱中。

<div id="lightbox">Here is clicked li and its content</div>

我真的不知道从哪里开始。

如何告诉jQuery获取li并放入div

1 个答案:

答案 0 :(得分:4)

你可以这样做:

$(document).ready(function() {
    $('li').on('click', function() {
        $('#lightbox').html($(this).html());
    });
});