gpt4 book ai didi

jquery - KENDO UI - 尝试在运行时添加 div

转载 作者:行者123 更新时间:2023-12-01 06:10:29 26 4
gpt4 key购买 nike

我试图在运行时添加一个带有 id 的 div 。然后同时尝试将 kendo ui 图表添加到该 div 中。但我无法做到这一点。如果有人有任何建议,很紧急。我有一个文本框,我在其中输入一个值,然后尝试添加该数字。

这是我的代码:

function createChart() { 
var noofcharts = document.getElementById('noOfCharts').value;

for(var i=1;i<=noofcharts;i++){
var varSlid = "chart"+i;
var div= $("<div id='+varSlid+' style='display:inline-block;width: 20%; height: 20%;border:2px solid;'></div>" );
$(document.body).append(div);
div.kendoChart({ series: [ { data: [1, 2] } ] });
}
}

错误如下:

Error: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol

最佳答案

试试这个:

function createChart() {
var noofcharts = $('#noOfCharts').val();

for (var i = 1; i <= noofcharts; i++) {
var varSlid = "chart" + i;
var div = $("<div id='"+varSlid+"' style='display:inline-block;width: 20%; height: 20%;border:2px solid;'></div>");
$(document.body).append(div);
div.kendoChart({ series: [
{ data: [1, 2] }
] });
}
}

这应该生成如下内容:

<body>
<div id="chart1" style="display: inline-block; width: 20%; height: 20%; border: 2px solid; position: relative;" data-role="chart" class="k-chart">
<!-- some codes for kendo chart -->
</div>
<div id="chart2" style="display: inline-block; width: 20%; height: 20%; border: 2px solid; position: relative;" data-role="chart" class="k-chart">
<!-- some codes for kendo chart -->
</div>
<div id="chart3" style="display: inline-block; width: 20%; height: 20%; border: 2px solid; position: relative;" data-role="chart" class="k-chart">
<!-- some codes for kendo chart -->
</div>
</body>

关于jquery - KENDO UI - 尝试在运行时添加 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19295905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com