【发布时间】:2015-10-08 15:28:36
【问题描述】:
我只想克隆并在这个克隆的右手边插入按钮。
我的 javascript 看起来像这样:
$('.frame .portlet').click(function (e) {
if ($(e.target).is(".portlet-content") || $(e.target).is(".portlet-header")) {
cancel: 'ui-icon-minusthick ui-icon-plusthick';
var $this = $(this), $error;
// for duplicate
if ($this.hasClass('added') && !$this.hasClass('newPortlet')) {
$error = $this.next('.clone-error');
if (!$error.length) {
$error = $('<span />', {
'class': 'clone-error',
html: '<div class="alert alert-warning" role="alert" style="width: 300px"> This question is already added!</div>'
}).insertAfter(this);
}
$error.stop().show().delay(800).hide(1);
} else if (!$this.hasClass('newPortlet')) {
$this.addClass('added').clone(document.getElementById(this.id)).addClass('newPortlet').("<button>hi</button>").appendTo('#creation .newFrame');
$msg = $('<span />', { html: '<div class="alert alert-success" role="alert" style="width: 300px"> This question is added to Add List!</div>' }).insertAfter(this);
$msg.stop().show().delay(800).hide(1);
count++;
add.html("<span id='newExam' class='badge' style='background-color: lightgreen; border-color: green'>" + count + "</span>");
}
}
});
我希望它是这样的:
【问题讨论】:
-
请向我们提供更多代码 (HTML) 甚至是 jsfiddle 链接,以便我们更好地帮助您;)
-
我认为你可以很简单地做到这一点,我推荐你,不要混合
pure js和jQuery。 jsfiddle 链接会很有用 -
clone(document.getElementById(this.id) === clone(this) -
我刚刚发布了 jsfiddle 链接,请检查并帮助我@highqweb
标签: javascript jquery html button clone