के साथ div जोड़ें, तो मैं यहां add a div पर और यहां add a class पर कैसे देखता हूं लेकिन मुझे दोनों को जोड़ने में समस्या हो रही है। मैं div sparkLineContainer के भीतर एक विशिष्ट वर्ग और आईडी के divs का एक पूरा समूह उत्पन्न करना चाहता हूँ।jquery, वर्ग परिभाषा
मैं युक्त div
<div id="#sparkLineContainer"></div>
है और मैं यह करने के लिए निम्न
<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>
// and so on
</div>
टुकड़ा का एक समूह जोड़ना चाहते हैं - मैं इसे बहुत दूर नहीं किया, मैं कर रहा हूँ स्टंप्डया
$('#sparkContainer').add("div"); \\ How do I add the id and class to this div?
\\ And as a repeat the function will it overwrite this?
फ़ंक्शन मैं इसे करने का प्रयास कर रहा हूं।
function renderSparklines (array1, sparkLineName, id) {
// array1 is the data for the spark line
// sparkLineName is the name of the data.
// Turn all array values into integers
arrayStringToInt(array1);
// Create new div of class sparkLines
$('#sparkContainer').add("div")
// Render new spark line to
$('.sparkLines').sparkline(array1, {width:'90px'});
var htmlString = ""; // Content to be added to new div
// GENERATE LITTLE SPARK BOX
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);
}
.add() फ़ंक्शन का नहीं जोड़ता है एक div यह सिर्फ मिलान चयनकर्ता को जोड़ता है। –