.htmlを使用して挿入されたクラス要素に到達しようとしています。クリックイベントを介して関数で呼び出すと機能しますが、まっすぐに呼び出すと...アイデアはありませんか?
$("#textarea).html("<div>Lorem ipusum<span class='note-content'>Note text</span>Lorem ipusum</div>");
function collapseNotes() {
$(".note-content").animate({
width:"50px",
opacity: ".3",
});
}
//this works
$("#button").click(function() {
collapseNotes();
});
//this doesn't work
collapseNotes();