jquery clone div and append it after specific div

后端 未结 4 523
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 03:58

\"enter

Hi guys, from the picture above, I want to clone the div with id #car2 and app

4条回答
  •  爱一瞬间的悲伤
    2020-12-03 04:39

    You can do it using clone() function of jQuery, Accepted answer is ok but i am providing alternative to it, you can use append(), but it works only if you can change html slightly as below:

    $(document).ready(function(){
        $('#clone_btn').click(function(){
          $("#car_parent").append($("#car2").clone());
        });
    });
    .car-well{
      border:1px solid #ccc;
      text-align: center;
      margin: 5px;
      padding:3px;
      font-weight:bold;
    }
    
    
    
    
    
    
    
    Normal div
    Clone div
    Normal div
    Normal div
    Normal div

提交回复
热议问题