<div class = "kindOfReason">
<div class = "chooseBtn">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<script>
window.onload = function(){
var ok = document.querySelector(".chooseBtn");
var ko = document.querySelector(".kindOfReason");
ok.onclick = function(ev){
var target = $(ev.target);
ko.append($(target).clone(true));
}
}
</script>
我想点击最小的div并将它复制给kindofreason 结果输出的却是[object object] ,console。log是undifind这是为啥
你这个啥都没有,空白的怎么点,而且逻辑也是错的,给你写了一个,直接复制去试试吧
<div class="chooseBtn" style="width:300px;height:100px;background-color:gray;color:white;">
<div>我是第一个div,点我复制到下面</div>
<div>我是第二个div,点我复制到下面</div>
<div>我是第三个div,点我复制到下面</div>
<div>我是第四个div,点我复制到下面</div>
</div>
<div style="height:100px;"></div>
<div class="kindOfReason" >
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
var ok = document.querySelector(".chooseBtn");
var ko = document.querySelector(".kindOfReason");
window.onload = function () {
ok.onclick = function (ev) {
var $chooseBtn = $('.chooseBtn').clone();
$('.kindOfReason').html($chooseBtn);
}
}
</script>