简体   繁体   English

窗口宽度大于769px时使用jquery追加和删除元素

[英]Append and remove element with jquery when width of window is greater than 769px

I'm trying something a bit different with slideshows when the window width reduces and expands in size. 当窗口宽度减小并扩大时,我正在尝试与幻灯片放映的方式有所不同。 I have the html code for two slideshows in slideshows.html. 我在slideshows.html中有两个幻灯片的html代码。 Slideshows are labeled: 幻灯片标记为:

<div class="slideshow-mobile">... </div>

<div class="slideshow-desktop">... </div>

I'd like to append '.slideshow-desktop', located in slideshow.html, into my '#featured' div, which is located index.html page, when the window width is greater than 769px. 当窗口宽度大于769px时,我想将位于slideshow.html中的“ .slideshow-desktop”附加到位于索引目录中的“ #featured” div中。

When the window width is less than 769px, I'd like to remove the code from the existing slideshow,'.slideshow-desktop', and then append '.slideshow-mobile' in #featured. 当窗口宽度小于769px时,我想从现有的幻灯片显示中删除代码“ .slideshow-desktop”,然后在#featured中附加“ .slideshow-mobile”。 In other words when window width is less than 769px I just want to replace '.slideshow-desktop' with '.slideshow-mobile'. 换句话说,当窗口宽度小于769px时,我只想将'.slideshow-desktop'替换为'.slideshow-mobile'。

I hope this makes since. 希望自此以后。 Would anyone know, or have a clue on how to do this? 会有人知道,或有关于如何执行此操作的线索吗?

我建议使用Adapt.js( http://adapt.960.gs/ ),它具有一个回调函数,您可以在其中依赖于宽度来添加/删除元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM