我正面临一个问题,我正在做的就是这个。我有一个服务器端图像按钮。我想做的是在客户端加载该页面后,我想将具有相同导航 url 的相同图像放在同一页面上的另一个位置。任何人都可以告诉我该怎么做吗?就像我也想用 javascript 在页面上隐藏一些文本一样。有什么想法吗??
最佳答案
使用.clone()
方法。
一个例子:
假设你的 img 是这样的
<img class="yourimageclass" src="Your/path/to/image.jpg" ?>
<!-- And this being where you want to copy it -->
<div class="whereuwanttocopy"></div>
那么你的 jQuery 就是
$('.yourimageclass').clone().appendTo('.whereuwanttocopy');
要在您的页面中隐藏一些文本,请将它们包装到某个容器中,以便我们可以处理那部分内容
<span class="todhide">here is the text to hide</span> and here is the text to not hide
然后只要您想隐藏文本,就可以使用简单的$(".tohide").hide()
关于javascript - 加载页面后如何使用javaScript在同一页面上添加重复图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4623265/