So, I see here add the div and here, how to add the class , but I had problems with combining the two. I want to create a whole bunch of divs of a specific class and id in a sparkLineContainer div.
I have a div div
<div id="#sparkLineContainer"></div>
and I want to add a bunch of the following to it:
<div id="#sparkLineContainer">
<div class="sparkLines" id="id1">Some stuff here</div>
<div class="sparkLines" id="id2">Some stuff here</div>
<div class="sparkLines" id="id3">Some stuff here</div>
</div>
snippet - I haven't done it very far, I'm at a standstill
$('#sparkContainer').add("div"); \\ How do I add the id and class to this div?
\\ And as a repeat the function will it overwrite this?
The function I'm trying to do this.
function renderSparklines (array1, sparkLineName, id) {
arrayStringToInt(array1);
$('#sparkContainer').add("div")
$('.sparkLines').sparkline(array1, {width:'90px'});
var htmlString = "";
htmlString +=
'<font class = "blueDescriptor">' + sparkLineName + '</font>'+
'<br>'+
'<font class = "greyDescriptorSmall">Ship to Shore</font>'+
'<br>'+
'<font class = "blackDescriptorSparkLine">' + array1[array1.length-1] + '</font>'+
'<font class = "greenDescriptorSparkline">(' + (array1[array1.length-1] - array1[array1.length-2]) + ')</font>' +
'<br>';
$('.sparkLines').prepend(htmlString);
}
source
share