如果要从后台读取数据,动态生成列表,后台有多少行,我们就显示多少行。这时候就不能将页面写死,下面是两种动态生成js的方法,也是因为这次做网站要用,就学到了。
下面是具体的代码:
其中的n可以是读取后台的记录数,具体输出内容也可后台读取,这里只是大体框架。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>动态列表</title>
</head>
<body>
<center>
<input type="button" value="创建" onclick="create()">
<input type="text" placeholder=" 创建数量" id