我有一个页面,它使用从div到javascript
函数的发送数据(在数字2下的示例中),但它似乎无法正常工作。警报出现,如图所示。有任何想法吗?
分割线
<div id="containerbar" data-F1="2" style="min-width: 200; height: 400px; margin: 0 auto"></div>
JAVASCRIPT
<script>
$(function () {
var $bardata = $("#containerbar");
var valueF1 = parseInt($bardata.data('F1'));
alert("Val1: " + valueF1);
$bardata.highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Teacher count per slider'
},
xAxis: {
categories: ['Feedback', 'Challenge & differentiation', 'Classroom talk', 'Skills development', 'Expectations & relationships'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Count',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
tooltip: {
valueSuffix: ' xx'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{
name: '1st quartile',
data: [valueF1 , 4, 1, 0, 0]
}, {
name: '2nd quartile',
data: [4, 4, 1, 0, 0]
},{
name: '3rd quartile',
data: [4, 4, 1, 0, 0]
}, {
name: '4th quartile',
data: [4, 4, 1, 0, 0]
}]
});
});
</script>
最佳答案
var valueF1 = parseInt($bardata.attr('data-F1'));