createElement auto listeners

59 views Asked by At

When I create input color class element, javascript adds listeners authomaticaly, but when I add by "add" function. listeners don't added authomatically. What can I do?

<script type="text/javascript">
function add() {
    alert("movida");
    var child = document.createDocumentFragment();
      var tmp = document.createElement('input');
     tmp.className = 'color';
      child.appendChild(tmp);
      document.body.appendChild(tmp);
}
</script>
</head>

<body>
 <input  class="color"  > 
 <input  class="color"  > 

<p onclick="add()" > add</p>
</body>

here is js file http://pastebin.com/yzja4iNV

1

There are 1 answers

0
user3123521 On BEST ANSWER

I just called jscolor.init(); end of function and it worked :)