javascript - Jquery Clone element Style -


i trying clone specific section of div style="background-color:<?php echo $mg ?>;"

so want happen when click specific button clones style part of div.

at moment getting error uncaught typeerror: $(...).attr(...).clone not function

here example of have:

$(function() {    $(".mapei-grout-color").click(function() {      $(this).attr('style').clone(true, true).appendto('#the-grid');      var $this = $(".grout-tab");      if ($this.hasclass("clicked-once")) {        $this.removeclass("clicked-once");        $(".mapei").slideup();      }    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

if understand question correctly, when click on 1 button, takes style of button , clones other button.

$('#style').on('click',function(){       document.getelementbyid('clone').setattribute('style',this.getattribute('style'));    }); 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <button style="background-color:blue" id="style">click here</button>  <button  id="clone">clone</button>


Comments