动态插入特定于单击div的html

时间:2015-03-25 16:37:40

标签: javascript jquery html css

我正在努力实现与此http://www.hausofmagdalen.com/非常相似的感觉。

使用jQuery .toggle我可以隐藏或显示特定于所选图库图像的图库上方的div(文本框)。但是,当连续单击多个图像时,我会显示所有文本框。换句话说,文本框不会相互抵消。

非常感谢解决方案。

2 个答案:

答案 0 :(得分:1)

所以,我根据自己的假设编写了一个例子。看看那是不是你想要的。



$(".items").on("click", "li", function() {
    $("#box").html($(this).html());
}).find("li").first().click();

#box { width: 250px; height: 100px; border: 1px solid; }
ul { overflow: hidden; margin: 10px; padding: 0; }
li { width: 80px; border: 1px solid green; overflow: hidden; float: left; margin: 0 10px; cursor: pointer; }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="box"></div>
<ul class="items">
    <li>As you can see, the reason behind is the willing to give as much as information I can whenever you inspect an element</li>
    <li>classes the porpouse is to have a placeholder with no style at all that we can bind with our javascript code without mixing</li>
    <li>In the first declaration you obviously understand that we are talking about a button but you might not be sure which one</li>
    <li>You have to trust me even if at first it might seems to be a bit silly but when your site grows up as much as your blocks </li>
</ul>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

这样的东西?

$('#gallery').html($('.selected-video').html());