The following code works fine in Firefox. In IE (8.0), the "2" button does not work.
$('<button type="button" onclick="alert(1)">1</button>').appendTo($('body'));
$('<button type="button" >2</button>').attr('onclick','alert(2)').appendTo($('body'));
Question: what am I doing wrong?
source
share