javascript - jQuery: is element.click(func) or element.attr('onclick','func()') more efficient? -
i'm populating list cloning elements it. change attrs make each item unique. need call function on click, i'm wondering if it's more efficient use new_element.click(func); or new_element.attr('onlick','func();');
new_element.attr('onclick','func();'); is:
inefficient (needlessly creating new inline function string, nothing except call func , lose
thisreference);aggravating put complex code in, since has js string escaped;
broken in ie, due bugs in
setattribute.
avoid. click()/bind('click') there reason.
Comments
Post a Comment