我需要动态添加数据表。我可以动态添加一个html表,但是它没有被转换为数据表。
我收到此错误: 对象不支持属性或方法'dataTable' 文件:test.html,行:12,列:13
这是测试代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da" lang="da">
<head>
<link rel="stylesheet" type="text/css" href="cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript" src="/script/jquery.dataTables.js"></script>
<script type="text/javascript">
jQuery(function () {
var s = "<table id='example'><thead><tr><th>Sites</th></tr></thead><tbody><tr><td>line1</td></tr><tr><td>line2</td></tr><tr><td>line3</td></tr></tbody></table>"
$('.add_to_this').append(s);
$('#example').dataTable();
});
</script>
</head>
<body>
<div class="add_to_this">
<p>test</p>
</div>
</body>
</html>
答案 0 :(得分:0)
答案 1 :(得分:0)
如果包含dataTables
css。