【问题标题】:How to use Javascript so that every time I click a image, its adds a new image below the item clicked on? [closed]如何使用 Javascript 以便每次单击图像时,它都会在单击的项目下方添加一个新图像? [关闭]
【发布时间】:2015-01-03 03:50:41
【问题描述】:

所以,如果标题对您来说没有意义,我将在这里更详细地介绍。首先,我将向您展示我想将其添加到的文档。

<html>
 <body>
  <div style="text-align:center"><!-- This is where the image that will be clicked on will be placed.--> </div>
  <div style="text-align:center"><!-- This is where I want the new images to show up. --></div>
 </body>
</html>

我希望这能让您对我希望这样做有一个基本的了解,但如果不是,我现在将进一步解释...... 因此,每次单击“image1”时,都会在其下方放置一个新图像,这是确定的,并且始终是“image2”。我将如何成功。 谢谢。

【问题讨论】:

  • 你的意思是灯箱类型的东西,下面的图片更大并显示描述?喜欢,cheesecakebb.org/index.php?action=viewgallery
  • 编写代码将是一个好的开始。我们是来帮忙的,而不是替你做你的工作。
  • 不,就像单击按钮时一样。一个完全不同的图像将添加到您单击的页面下方。

标签: javascript jquery html css


【解决方案1】:

让您开始:

当您在main 内部单击时,一个新图像会附加到new

$('#main').click(function() {
  $('#new').append("<img src='http://placehold.it/140x100' />");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="text-align:center" id='main'>
  <img src='http://placehold.it/350x150' />
</div>
<div style="text-align:center" id='new'></div>

【讨论】:

    猜你喜欢
    • 2015-09-19
    • 2014-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多