3 回答

TA贡献1804条经验 获得超7个赞
看看这个解决方案。不太确定你在问什么,但这似乎可能有帮助。
function reply_click(clicked_id)
{
console.log(clicked_id);
if(clicked_id !== "00")console.log('do stuff');
}
function check(event)
{
if(document.getElementById(event.id).checked)
{
reply_click(event.id);
}
}
<button id="00" onclick="reply_click(this.id)"></button>
<input type="radio" id="1s" name="ship" onclick="check(this)">
<label for="1s">1 square ship</label><br>

TA贡献1836条经验 获得超3个赞
仅当选中按钮时,您才可以使用disable该按钮enableradio
function reply_click(clicked_id) {
console.log("Definaley i am not disabled now: "+clicked_id);
}
function check()
{
if(document.getElementById('1s').checked)
{
document.getElementById("00").disabled = false;
document.getElementById("00").innerText = "Now i am enable";
}
}
<input type="radio" id="1s" name="ship" onclick="check()">
<label for="1s">1 square ship</label><br>
<button id="00" onclick="reply_click(this.id)" disabled>I am disabled</button>

TA贡献1772条经验 获得超5个赞
在reply_click中添加if语句..例如:
function reply_click(clicked_id) {
if (document.getElementById('1s').checked) {
// Do stuff
}
}
- 3 回答
- 0 关注
- 89 浏览
添加回答
举报