也许我在这里错过了一些简单的东西.. “添加”按钮不会触发要添加到li的项目。 “启动任务”按钮目前并不重要。
谢谢!
function add() {
var a = document.getElementById("input_txt").value;
var b = document.getElementById("items");
var tag = document.createElement("li");
tag.innerHTML = a;
b.append(tag);
document.getElementById("input_txt").value = "";
}
<!DOCTYPE HTML>
<title>TaR</title>
<link href="style.css" rel="styelsheet" />
<body>
<div>
<section>
<input type="text" placeholder="Enter Item" id="input_txt" />
<button onclick="add(0" id="add_txt">Add</button>
</section>
<ul id="items">
</ul>
<section>
<button onclick="Launch(0" id="launch_task">Launch Task</button>
</section>
</div>
<script src="script.js"></script>
</body>
答案 0 :(得分:0)
你错过了一个括号:
k
发件人强>
<button onclick="add(0" id="add_txt">Add</button>
<button onclick="Launch(0" id="launch_task">Launch Task</button>
要强>
add(0
Launch(0
答案 1 :(得分:0)
您输错了,请fun showDocument() {
var documentLayout: TableLayout = findViewById(R.id.document_layout)
val row = TableRow(documentLayout.context)
val inputField = EditText(row.context)
inputField.setScroller(Scroller(documentLayout.context))
inputField.maxLines = 1
inputField.isVerticalScrollBarEnabled = true
inputField.isHorizontalScrollBarEnabled = true
inputField.movementMethod = ScrollingMovementMethod()
inputField.overScrollMode = EditText.OVER_SCROLL_IF_CONTENT_SCROLLS
val label = TextView(row.context)
label.text = "Label"
label.labelFor = inputField.id
row.addView(label)
row.addView(inputField)
documentLayout.addView(row)
}
失踪),应该是<button onclick="add(0" id="add_txt">Add</button>
但最好以编程方式设置事件监听器。
在您的脚本中添加:
<button onclick="add(0)" id="add_txt">Add</button>