为什么两个元素的标签内标签不起作用
why label inside label for two element not working
在我的代码中,第二个输入的标签 "Two" 设置在第一个输入的标签 "One" 中,但是当点击标签 "Two" 时,第一个输入未激活。
HTML:
<input type="checkbox" id="inp_one">
<input type="checkbox" id="inp_two">
<div>
<label for="inp_one">
<h1>One</h1>
<label for="inp_two">
<h1>Two</h1>
</label>
</label>
</div>
我的代码:https://jsfiddle.net/5x6ytk3g/
我想要点击标签 "Two" 然后激活两个输入。
我认为你需要使用 JavaScript:
document.getElementById("inp_two").onchange = function(){
document.getElementById("inp_one").checked = this.checked;
};
https://jsfiddle.net/5x6ytk3g/1/
我试过了。祝越南好运!
在我的代码中,第二个输入的标签 "Two" 设置在第一个输入的标签 "One" 中,但是当点击标签 "Two" 时,第一个输入未激活。
HTML:
<input type="checkbox" id="inp_one">
<input type="checkbox" id="inp_two">
<div>
<label for="inp_one">
<h1>One</h1>
<label for="inp_two">
<h1>Two</h1>
</label>
</label>
</div>
我的代码:https://jsfiddle.net/5x6ytk3g/
我想要点击标签 "Two" 然后激活两个输入。
我认为你需要使用 JavaScript:
document.getElementById("inp_two").onchange = function(){
document.getElementById("inp_one").checked = this.checked;
};
https://jsfiddle.net/5x6ytk3g/1/
我试过了。祝越南好运!