我可以使用 jQuery 加载和卸载图库吗?
我正在制作一个作品集网站,其中每个项目都可以通过单击展开,并且内部有一个图片库。
我面临的问题是,一旦加载许多图像,网站就会变得非常慢。有没有办法在单击时加载内容,一旦我单击其他项目,以前的画廊内容就会完全卸载?
我对 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单击后,创建一个新的 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();