首页
IT
登录
6mi
u
盘
搜
搜 索
IT
使用js写一个简单的判断年龄是否达标的页面
使用js写一个简单的判断年龄是否达标的页面
xiaoxiao
2021-04-18
77
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>
414
</
title
>
</
head
>
<
body
>
<
p
id
=
"demo1"
>
</
p
>
<
p
>
点击按钮检测年龄
</
p
>
年龄:
<
input
id
=
"age"
,value="18"
/>
<
p
>
是否达到投票年龄?
</
p
>
<
button
onclick
=
"myFunction()"
>
点击按钮
</
button
>
</
button
>
<
script
>
function
myFunction
()
{
var
age,voteable; age=document.getElementById(
"age"
).value; voteable=(age<
18
)?
"年龄太小"
:
"年龄已达到"
; document.getElementById(
"demo"
).innerHTML=voteable; }
</
script
>
<
p
id
=
"demo"
>
</
p
>
</
body
>
</
html
>
转载请注明原文地址: https://ju.6miu.com/read-675578.html
技术
最新回复
(
0
)