我是jquery和javascript整体的新手。我试着做两件事,但其中只有一件正在工作。我必须改变颜色,以及增加计数器,如下所述。需要帮助的代码。 例子 -jquery的两个元素
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/
应避免到这里来的链接和“去弄明白“声明。在这里向我们提出问题,在帖子中提供破碎的代码,然后根据需要提供jsfiddle的链接。你甚至没有说明你的问题是为了帮助我们。 – Yatrix