尝试通过点击增加数字,你可以通过点击我的jsfiddle看到我遇到的问题,前两次点击注册0然后数字一次增加10个
http://jsfiddle.net/jamcrowe/LvwDb/1/
var online = 0;
var creative = 0;
var technical = 0;
var analyst = 0;
var managerial = 0;
function me() {
$('#one').click(function(){
creative +=5;
online ++;
managerial ++;
});
$('#two').click(function(){
creative +=5;
online ++;
managerial ++;
});
$('#three').click(function(){
creative +=5;
online ++;
managerial ++;
});
alert(creative, online, managerial);
}
答案 0 :(得分:1)
您正在jQuery和DOM中绑定事件。我不完全确定你在寻找什么,但我猜它是这样的:http://jsfiddle.net/wnfBn/
var online = 0;
var creative = 0;
var technical = 0;
var analyst = 0;
var managerial = 0;
$('#one,#two,#three').click(me);
function me() {
creative += 5;
online++;
managerial++;
alert(creative + ':' + online + ':' + managerial);
};