I have the following code which only populates 1 of the divs:
$(function () {
var $container = $('.portlet_content_18');
var chart = new Highcharts.Chart({
chart: {
renderTo: $container[0],
height: 400
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
Where the HTML looks something link this:
<div class="portlet_content_18">
<div class="portlet_content_18">
How do I get it to populate both divs? Or all the divs if there are 10, 20, 100 or more identical divs with the same class?
Here is a jsfiddle: http://jsfiddle.net/Chmts/
Use $.each :
$('.portlet_content_18').each(function(){
var chart = new Highcharts.Chart({
chart: {
renderTo: this,
height: 400
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
}));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.