使用javascript和php,在单击图像时将其移动到另一个位置

Make an image move to another place when it is clicked on, using javascript and php?

本文关键字:移动 位置 另一个 图像 javascript php 单击 使用      更新时间:2024-05-07

所以我有一个带有图像的PHP页面。当点击每一张图片时,我希望它们在页面上移动,然后隐藏起来。

<div class="lagoon">    
<img src="images/lagoon.jpg" alt="lagoon" id="LL"/>
<p class="text">Lagoon</p>
</div>

这是我的一张图片的代码。我现在需要进入Javascript,并使它在点击时移动。

$ ("LL").click(function (){
$ ("div").animate ({left:'250px'});
});

我试过这个,还有很多其他的东西,请帮忙。

您的CSS选择器不正确。使用#以元素的id为目标。

$("#LL").click(function (){
  $("div").animate({left:'250px'});
});