当以这种方式设置时,点击具有子按钮的标签会触发按钮的onclick事件:
function fireButton() {
console.log("Button fired!");
}
<label>Label
<button onclick="fireButton()">Button</button>
</label>
有没有办法防止这种情况发生?