我正在尝试添加一个字符d,其值为this.id,由下面的代码给出:dclicki25。我怎么能得到这个?
$('.divclasss').click(function(){
console.log(this.id); //clicki25 , clicki26 based on the clicking element
});
答案 0 :(得分:2)
只需与此
连接 d$('.divclasss').click(function(){
console.log('d'+ this.id); //clicki25 , clicki26 based on the clicking element
});
答案 1 :(得分:0)
您可以使用以下小变化非常轻松地将this.id与字符串'd'连接起来:
$('.divclasss').click(function(){
console.log('d'+ this.id); //clicki25 , clicki26 based on the clicking element
});