Я просто хочу клонировать и вставлять кнопку в правой руке этого клонированного.Как клонировать div и вставить кнопку вместе?
мой 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 ссылку, чтобы мы может помочь вам лучше;) – nstungcom
Я думаю, вы можете сделать это очень просто, и я рекомендовал вам, не смешивайте 'pure js' и' jQuery'. jsfiddle ссылка будет полезна –
'clone (document.getElementById (this.id) === clone (this)' – charlietfl