Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下のコードでは、メソッドが新しいjqueryオブジェクトを生成した後に実行します。そうでない場合、addClassメソッドがdiv要素とp要素の両方でaddindクラス'foo'である理由
$('<div/>').after('<p></p>').addClass('foo') .filter('p').attr('id', 'bar').html('hello') .end() .appendTo('body');
この正確なシナリオは、jQueryAPIで説明されています。
「結果は、divと段落をこの順序で含むjQueryセットです。」
http://api.jquery.com/after/