简体   繁体   English

删除克隆的jQuery UI按钮将删除基本按钮的样式

[英]Removing cloned jQuery UI button will remove base button's style

I've set up this Fiddle for you: http://jsfiddle.net/MNpRh/4/ 我已经为您设置了该提琴: http : //jsfiddle.net/MNpRh/4/

$("#removebtn").button();
$(document).on("click", ".remove", function(){
   $(this).remove();
});
$("#clone").click(function(){
   $("#removebtn").parents(".group").clone(true).appendTo("#content");
});

Hit Clone a couple times then remove any button. 点击克隆几次,然后删除任何按钮。 The button style will be removed and not cloned again. 按钮样式将被删除,不会再次克隆。

It's based on jQuery UI 1.8. 它基于jQuery UI 1.8。 It works in 1.10, but I'm not able to upgrade jQuery UI. 它可以在1.10中运行,但是我无法升级jQuery UI。

How would you solve this? 您将如何解决?

Thanks in advance! 提前致谢!

To keep hover effect please see modified solution with added pattern div which is hidden by CSS http://jsfiddle.net/MNpRh/8/ 为了保持悬停效果,请参见CSS模式http://jsfiddle.net/MNpRh/8/隐藏的带有模式div的修改后解决方案

Addition to HTML: 除了HTML:

<div class="group" id="pattern">
     <button class="remove">Remove me</button>
</div>

CSS: CSS:

#pattern { display:none;}

JQuery: JQuery的:

$("#removebtn").button();
$(document).on("click", ".remove", function(){
    $(this).remove();
});
$("#clone").click(function(){
  $('#pattern').clone().appendTo("#content").removeAttr('id').find('button').button();
});

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

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