如何在javascript中获取复选框值
我的HTML脚本是如何在javascript中获取复选框值,javascript,html,checkbox,html-input,Javascript,Html,Checkbox,Html Input,我的HTML脚本是 <html> <body> <b><font color="green">Please select a check box to change the color of text </font> </b><br> <input type="checkbox" name="red" id="chkbx" > Red<br>
<html>
<body>
<b><font color="green">Please select a check box to change the color of text </font> </b><br>
<input type="checkbox" name="red" id="chkbx" > Red<br>
<input type="checkbox" name="green" id="chkbx" value="1"> Green <br>
<input type="checkbox" name="blue" id="chkbx" value="2"> Blue <br>
<input type="checkbox" name="orange" id="chkbx" value="3"> Orange <br>
<input type="checkbox" name="yellow" id="chkbx" value="4"> Yellow <br>
<p id="demo"></p>
<button onclick="myfunction()">My Choice</button>
<br><br>
<h style="color: red; font-weight: bold;"> </h>
<p id="demo"></p>
请选中复选框以更改文本的颜色
红色
绿色
蓝色
橙色
黄色
我的选择
我需要获取javascript中的复选框值,如果选中任何一个复选框,该颜色将应用于文本以显示在输出上。如何做?首先-不要使用该标记,因为它自1999年使用以来就被弃用了
<p style='font-weight:bold; color:green'>....</p>