Yes, if you look at it from another angle, the cycle will save a lot of effort; if you look at it this way, it will be much clearer
.
for(var i=0;i<10;iPP){
$("-sharpapp).append('<div class="div1">' +i+ '<h3 class="box-title"></h3>' +
'</div>');
}
means to append 10 div tags
double quotation marks to app elements in id.
actually has no special meaning but a string concatenation, so why concatenate it? Because you added the class name to div
the stitching rules are as follows:
double quotation marks are enclosed in double quotation marks, or double quotation marks are enclosed in single quotation marks
now go back to your code. If your class name is still in single quotation marks, it will be parsed as a long string (including your div)
if you have no other variables in it, you can write
like this.
'<div class="div1"><h3 class="box-title"></h3></div>';h3
'<div class="div1"><h3 class="box-title">' +H3+ '</h3>' + '</div>'
I hope I can help you
there are no variables between the div tag and the h3 tag, so there should be no need to separate them. Just write it in a string.
string concatenation is not necessary, it can not be used at all! Here is the proof
:
const a = {
boxHeaderTemplate : '<div class="div1"><h3 class="box-title"></h3></div>',
boxHeaderTap : '<div class="div2"><h3 class="box-title"></h3></div>',
}
const b = {
boxHeaderTemplate : '<div class="div1">' + '<h3 class="box-title"></h3>' + '</div>',
boxHeaderTap : '<div class="div2">' + '<h3 class="box-title"></h3>' + '</div>',
}
console.log(a.boxHeaderTemplate === b.boxHeaderTemplate); // true
console.log(a.boxHeaderTap === b.boxHeaderTap) // true
run it yourself ~