的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
'$('