I usually use custom variables for elements in javascript. something like this:
document.getElementById("test").myVar=function(){
// do something
};
now I need to copy one element (document.getElementById("test")) and append it somewhere. I tried to use clone() with jquery. something like this:
$("#test").clone(true,true).attr("id","test2").appendTo("#somewhere");
but it can’t copy myVar in the new element. how can I fix it?
Why, oh why do you assign arbitrary properties to the elements ?
Since you use jQuery why not use the
.data()method ? (although i still cannot understand why you would store a function on an element..)A different abuse could be to bind a custom event handler (namespaced to avoid further issues), but i would stick with
.data()