学习使用Bottle.py并使用按钮制作页面:
<!DOCTYPE html>
<html>
<head><title>button</title></head>
<body>
<script>function test(){
console.log("a");
document.getElementById("b").innerHTML = "abcd";
return false;}</script>
<form onsubmit="return test()">
<button type="submit">Button</button>
</form>
<div id="b"></div>
</body>
</html>
当我按下按钮时,在javascript控制台上没有打印出来.div元素没有填充文本。
from bottle import route, template, run
@route('/button')
def b():
return template('button')
这显然是我应用程序实际发生的缩小版本。
答案 0 :(得分:1)
您的javascript和html代码完全有效,因为@Blender说,您是否通过查看http响应提供的实际来源来检查您是否拥有有效代码?