【问题标题】:Clone Append Jquery stops effect克隆追加 Jquery 停止效果
【发布时间】:2018-04-24 08:51:03
【问题描述】:

克隆的视差 jquery 在附加到 dom 后停止工作。 检查我的例子:https://codepen.io/anon/pen/rYOrEO

HTML:

<div class="container">
  <a href="#" class="clone">Clone</a>
</div>
<section class="content">
  <div class="jumbotron text-center bg-faded my-5" style="background: url('http://lorempixel.com/1200/600/abstract/1') no-repeat center;" data-paroller-factor="0.5">
    <h1 class="heading-1 py-5 text-white">Hello Parallax!</h1>
  </div>
</section>

JS:

$(window).paroller();
$(function(){
  $('.clone').on('click', function() {
    alert('hi');
    $(".jumbotron").clone().appendTo(".content");
  });
});

【问题讨论】:

    标签: javascript jquery html clone


    【解决方案1】:

    随便用

    $('#grolsh').clone(); // Copies the element structure
    
    $('#grolsh').clone(true) // Copies both data and events along with the structure
    
    $('#grolsh').clone(true).off() // Copies both data and events and removes handlers
    
    Events bound with .on() and removed using .off();
    
    Events bound with .bind() and removed using .unbind();
    

    //您更新的代码可能会有所帮助

    $(window).paroller();
    $(function(){
      $('.clone').on('click', function() {
        alert('hi');
            $(".jumbotron").clone(true).prependTo(".content");
            $(window).paroller();
      });
    });
    

    ref

    【讨论】:

    • 这也行不通,你能通过我在链接上添加的示例向我解释一下吗:codepen
    猜你喜欢
    • 2016-07-01
    • 2018-02-11
    • 2011-10-22
    • 2017-06-30
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多