I have an array of strings, which I loop through and display the string and their respective div, But the strings have HTML, and I would like them to be actual HTML and not a string of text like they are currently being displayed.
My HTML :
<div class="line__0"></div>
<div class="line__1"></div>
<div class="line__2"></div>
jQuery :
var textLines = [
"Line <strong>0</strong>.",
"Line <strong>1</strong>.",
"Line <strong>1</strong>."
];
function text(i) {
for (i = 0; i < textLines.length; i++) {
$('.line__' + i).html(textLines[i]);
}
}
itotext()method doesn't make sense here because anyway you are redefiningiin loop declaration, even it shoudl be:for (var i = 0;...). That's said, you don't need anyforloop here: jsfiddle.net/nqj30mz0/1