在jquery replacewith()方法之后执行owl-carousel脚本(DOM元素替换) [英] Execute owl-carousel script after jquery replacewith() method (DOM elements replacement)

查看:93
本文介绍了在jquery replacewith()方法之后执行owl-carousel脚本(DOM元素替换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的jsFiddle



准备好文件我想要:



1.用3个div替换3个div(带有类:'one','two','three'')(每个div都相同使用jQuery replaceWith()方法的类'smilling'),


2.运行owl-carousel插件。



我不知道为什么但是虽然dom元素更换确实成功了owl-carousel不加载..有什么建议吗?我为什么要这样做?它与MediaQueries有关...



我尝试过:



我的jQuery:



Here is my jsFiddle

On document ready I want to:

1. Replace 3 divs (with classes:' one', 'two', 'three'') with 3 divs (each one with the same class 'smilling') with jQuery replaceWith() method,

2. Run the owl-carousel plugin.

I don't know why but although dom elements replacement does go successful owl-carousel does not load.. Any suggestions? Why do I want to do this? It has something to do with MediaQueries...

What I have tried:

My jQuery:

$(document).ready(function() {

    $("div.super").replaceWith('<div class="smilling item"></div><div class="smilling item"></div><div class="smilling item"></div>');

$('.owl-carousel').owlCarousel({
                    loop:false,
                    nav:true,
                    items:1
                });

});

推荐答案

(document).ready(function(){
(document).ready(function() {


( div.super)。replaceWith('< div class =smilling item>< / div>< div class =smilling item>< / div>< div class =smilling item >< / div>');
("div.super").replaceWith('<div class="smilling item"></div><div class="smilling item"></div><div class="smilling item"></div>');


('。owl-carousel')。owlCarousel({
loop:false,
nav:true,
项目:1
});

});
('.owl-carousel').owlCarousel({ loop:false, nav:true, items:1 }); });


这篇关于在jquery replacewith()方法之后执行owl-carousel脚本(DOM元素替换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆