jQueryクックブック DOM要素の作成、操作、挿入

今まではセムーのサイトや本家のドキュメントを読みつつなんとか凌いだ感じだったけど、改めて勉強してみてjQueryとても使えると思った。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja" dir="ltr" id="R1">
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
div { width:70px; height:70px; background:#774422; margin:5px; float:left; padding:5px; font-size:small;}
</style>
</head>
<body>
<div id="test" style="background:blue;">test</div>
</body>

<script type="text/JavaScript" src="./jquery-1.4.2.js"></script>
<script type="text/JavaScript">
$('<div>prependTo</div>').prependTo('body');
$('body').prepend('<div>prepend</div>');

$('<div>appendTo</div>').appendTo('body');
$('body').append('<div>append</div>');

$('#test').before('<div>before</div>');
$('<div>insBefore</div>').insertBefore('#test');

$('#test').after('<div>after</div>');
$('<div>insAfter</div>').insertAfter('#test');


function c(obj){
	console.log(obj);
}
</script>
</html>