将带有属性的HTML内容附加到jQuery选择器

我想在选定元素中添加带有属性的DIV标记。 据我所知,根据jQuery网站插入HTML内容的正常方法是:

$('#selected_element').append('
{HTML CONTENT}
');

但是,我还需要同时在DIV标签上添加鼠标事件。 我注意到有一种方式看起来像这样:

 $('#selected_element').append($('
', { mouseover: function(){alert('mouseover');}, mouseout: function(){alert('mouseout');} }));

如何组合这两种方法来添加内容和属性?

 var $div = $('
{content}
').attr('attrName', 'attrVal').hover( function() { alert('mouseover'); }, function() { alert('mouseout'); } ); $('#selected_element').append($div);