I have the following two scripts. The first one works no problem. The second one however, will not clone anything. I am unsure how to fix this code, I'm very new. I am only doing the removeAttr ID because I read that could have been an issue on a similar thread, but it did not seem to help. Thank you in advance.

<head>
  <scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
      $("#roster").click(function(){
        var temp = $("#Characters").val();
        var count = 0
        var res = temp.split(",");
        res.forEach(function(name) {
          $('#row'+count).html(name)
          $('#row'+count).attr("onclick","console.log('"+name+"')");
          count++; 
        }); 
      }); 
    });
  </script>

  <scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
      $("#match1top").click(function(){
        $('#row0').clone().removeAttr("id").appendTo('#row1');
      }); 
    });
  </script>
</head>

1 Answers

0
Hien Nguyen On

Not sure your issue, i tried to reproduce it, it worked.

$(document).ready(function(){
  $("#match1top").click(function(){
  $('#row0').clone().removeAttr("id").appendTo('#row1');
 }); });
#row1{
border: 1px solid blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


<button id="match1top">Match</button>
<div id="row0">row0</div>
<div id="row1">row1</div>