的ID考虑下面的代码:我怎么可以设置一个变量的值作为jQuery中
var counter = 0; //counter variable
$('#divfuerimage').on('click', function(evt){
counter= counter+1; //count up
alert(counter);
var containerX = evt.pageX - $(this).offset().left,
containerY = evt.pageY - $(this).offset().top;
$('<div class="child" id=/*here the value of counter should be*/></div>')
我如何使用我的计数器变量的值作为ID?
您的前提存在缺陷:在HTML4.1及更低版本中,所有数字的“id”属性均无效。它们在HTML5中有效,但不在CSS3中,因此无法可靠地匹配它们。 – 2014-09-01 09:46:27
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition。 – VisioN 2014-09-01 09:43:24
'$('