我可以使用 jQuery 加载和卸载图库吗?

发布于 2024-11-14 07:26:44 字数 159 浏览 3 评论 0原文

我正在制作一个作品集网站,其中每个项目都可以通过单击展开,并且内部有一个图片库。

我面临的问题是,一旦加载许多图像,网站就会变得非常慢。有没有办法在单击时加载内容,一旦我单击其他项目,以前的画廊内容就会完全卸载?

我对 jQuery 不太有经验,所以这个例子会有很大帮助。

I'm making a portfolio site in which each project expands on click and inside there's a image gallery.

The problem I'm facing is that the site gets pretty slow once many images are loaded. Is there a way to load the content on click and once I click some other project, the previous gallery content to be completely unloaded ?

I'm not very experienced with jQuery so an example of this would help a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

皇甫轩 2024-11-21 07:26:44

单击后,创建一个新的 div,加载要在该 div 内显示的所有内容并将其显示给用户。那里有一个按钮可以关闭它。完成后,销毁该 div。

要创建 div,请阅读: 在 jQuery 中创建 div 元素

销毁它$('#div_id').remove();

Once you click, create a new div, load everything you want to show inside that div and show it to the user. Have a button there to close it. Once you do, destroy the div.

To create the div read: Creating a div element in jQuery

To destroy it just $('#div_id').remove();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文