HTML javascript 复选框函数
HTML javascript checkbox function
我有一个场景,当我选中 Bills Available 复选框时,应该弹出图像上传相机功能。我可以稍后为 "Image Upload" 编写 came 函数。但是当我检查 "Bills Available"
时,我需要显示 "Image Upload"
function calc()
{
var update=false;
console.log("update is" + update);
}
<td><input class="pop" id="exp" type="checkbox" name="bill available" value="" onchange="calc();"/>Bill available<br></td>
像这样:
window.onload = function() {
document.getElementById("exp").onclick = function() {
document.getElementById('upload').className = this.checked ? '' : 'hide';
}
}
window.onload = function() {
document.getElementById("exp").onclick = function() {
document.getElementById('upload').className = this.checked ? '' : 'hide';
}
}
.hide {
display: none
}
<input class="pop" id="exp" type="checkbox" name="bill_available" value="" /><label for="exp">Bill available</label>
<div class="hide" id="upload">Upload</div>
清理后使用您的代码:
window.onload = function() {
document.getElementById("exp").onclick = function() {
document.getElementById('upload').className = this.checked ? '' : 'hide';
}
}
.hide {
display: none
}
<table>
<tr>
<td>
<input class="pop" id="exp" type="checkbox" name="bill_available" value="" />
<label for="exp">Bill available</label>
</td>
<td class="hide" id="upload">
<img id="p2" src="./images/camera 40.PNG" style="width:30px;height:30px;"
onclick="window.location='4s.html'" /><b>Image Upload</b>
</td>
</tr>
</table>
我有一个场景,当我选中 Bills Available 复选框时,应该弹出图像上传相机功能。我可以稍后为 "Image Upload" 编写 came 函数。但是当我检查 "Bills Available"
时,我需要显示 "Image Upload"function calc()
{
var update=false;
console.log("update is" + update);
}
<td><input class="pop" id="exp" type="checkbox" name="bill available" value="" onchange="calc();"/>Bill available<br></td>
像这样:
window.onload = function() {
document.getElementById("exp").onclick = function() {
document.getElementById('upload').className = this.checked ? '' : 'hide';
}
}
window.onload = function() {
document.getElementById("exp").onclick = function() {
document.getElementById('upload').className = this.checked ? '' : 'hide';
}
}
.hide {
display: none
}
<input class="pop" id="exp" type="checkbox" name="bill_available" value="" /><label for="exp">Bill available</label>
<div class="hide" id="upload">Upload</div>
清理后使用您的代码:
window.onload = function() {
document.getElementById("exp").onclick = function() {
document.getElementById('upload').className = this.checked ? '' : 'hide';
}
}
.hide {
display: none
}
<table>
<tr>
<td>
<input class="pop" id="exp" type="checkbox" name="bill_available" value="" />
<label for="exp">Bill available</label>
</td>
<td class="hide" id="upload">
<img id="p2" src="./images/camera 40.PNG" style="width:30px;height:30px;"
onclick="window.location='4s.html'" /><b>Image Upload</b>
</td>
</tr>
</table>