私は全体としてjqueryとjavascriptが初めてです。私は2つのことを試みましたが、そのうちの1つだけが機能しています。以下で説明するように、色を変更するだけでなく、カウンターを増やす必要があります。コードのヘルプが必要です。例 -
1 click - 1
2 clicks - 11
5 clicks - 11111
コード - HTML
<div id="flash"> <p>hello</p>
</div>
<div id="counter">0</div>
コード - JAVASCRIPT
$(document).ready(function() {
$('p').click(function() {
$(this).animate({
'color': 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')'
}, 500);
});
$("#flash").click(function() {
$('#counter').html(function(i, val) {
return val * 1 + 1;
});
});
});
コード - CSS
p { font-weight: bold; display: inline; cursor: pointer; }
これが私が試してみた私のコードです - http://jsfiddle.net/crlf/pVHYc/