200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 点击按钮触发事件

点击按钮触发事件

时间:2021-11-25 01:10:24

相关推荐

点击按钮触发事件

HTML点击按钮触发事件

在使用button时,如何点击按钮触发事件?方法一:使用from表单中的action(仅有一个button时)方法二:设置onclick点击事件(多个button时)

在使用button时,如何点击按钮触发事件?

方法一:使用from表单中的action(仅有一个button时)

form action=“你需要跳转的页面”

button type=“设定类型”

eg:

<form action="check.jsp" method="get">用户名<input type="text" name="username" /><br>密码<input type="password" name="psd" /><br><br><button type="submit">登录</button></form>

方法二:设置onclick点击事件(多个button时)

form name=“起个名字”

input type=“button” οnclick=“document.刚起的名字.action=‘需要跳转的页面’;document.form1.submit()”

eg:

<form name="form1" method="get">用户名:<input type="text" name="username" />密码:<input type="password" name="psd" /><input type="button" value="登录" onclick="document.form1.action='check.jsp';document.form1.submit()"><input type="button" value="注册" onclick="document.form1.action='register.jsp';document.form1.submit()"></form>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。