オワタcheckbox(with jQuery)

ソース

--- owata3.js ---
/* -----------------------------
1. jqueryとこのjsを読む
2. 使いたいチェックボックスに class="owata" を指定する
3. チェックボックスのinput要素はlabelの中に置く
	ex:	<label><input type="checkbox" class="owata">hoge</label>
----------------------------- */
$(function(){
	$("input.owata").each(function(){
		$(this).parent().append('<span class="owataface">>\(^o^)/</span>');
		of=$(this).parent().find(".owataface");
		(this.checked)?of.show():of.hide();
		$(this).click(function(){
			(this.checked)?$(this).parent().find(".owataface").show():$(this).parent().find(".owataface").hide();
		});
	});
});



snowland.net