您的位置:首页 > Web前端 > HTML

html之checkbox------checkbox只是input框的type属性

2016-02-26 23:59 561 查看
<html>
<body>

我喜欢自行车:<input type="checkbox" id="Bike">
<br />
我喜欢汽车:<input type="checkbox" id="Car">
<br />
<button onClick="output()">test</button>

<script>
function output()
{
if(document.getElementById("Bike").checked)
{
alert("1");
}

if(document.getElementById("Car").checked)
{
alert("2");
}
}
</script>
</body>
</html>

        是否选中, 直接看selected这个属性。

        另外注意, 在html中, checkbox并不是一个单独的标签, 而是input框的type属性, 这和我之前玩过的BCB/VC++不一致。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: