こんな感じで、スパンオンクリック機能を使って、クリックすると内容が変化します。私は自分のフォームにjqueryを使用しています。コードはここにあります。クリックしたときにテキストを変更するには?
<form action="">
<span id="checkall"><a href="javascript:void(0);">select all</a></span>
<div class="all">
<input id="" name="" type="checkbox" /> 1
<input id="" name="" type="checkbox" /> 2
</div>
</form>
$(function() {
var obj = $('input[type="checkbox"]');
var txt = $('#checkall').text();
//alert(txt);
$('#checkall').on('click', function(e) {
obj.each(function() {
this.checked = ! this.checked;
// use if ( this.checked)
// text change its value
})
})
})
コードを jsfiddle に置きました: http://jsfiddle.net/huapei/6UfS2/1/