problems with cloning

problems with cloning

  1. function editMode(el){
  2.  var elm=$(el).clone(true);

  3. //work with  elm, ad input elements 

  4. $(el).replaceWith(elm);
  5. return el;
  6. }  

  7. var p=$(".editArea").first();
  8. var pp= p.clone();
  9. p.before(pp);
  10. ppp=editMode(pp);

  11. //code below don't work, all elements input must  nulled, without cloning code work
    //t.length==0
  12. td=$(ppp).find("td,span"); 
  13. $(td).each(function(){
  14. var t=$(this).children("input");
  15. if(t.length){
  16. t.val("");
  17. } });