このサンプルは、jQueryでanchor要素を実行時に生成して表示します。anchor要素を生成するとき属性とCSSも同時に追加します。[Run!]ボタンをクリックすると、div#placeholderにa#lnk要素が追加されます。
jQuery(...)で、anchor要素を生成するとき、引数2にanchor要素の属性、CSSなどが指定できます。ここでは、id, href, title, target属性とCSSのcolor,textDecorationプロパティを追加しています。textを追加するとjQueryは、内部的に.text()を実行してアンカーテキストを追加します。
$('<a />', {
id: 'lnk',
href: 'http://jquery14.com/',
title: 'jQuery 1.4',
target: '_blank',
text: 'The 14 Days of jQuery',
css: {
color: 'red',
textDecoration: 'none'
}
}).appendTo('#placeholder');