![](/img/trans.png)
[英]How do I write 'input[type="radio"]:checked + label' inside state in React?
[英]I'm trying to put a <button> inside an <input type=“radio”>'s <label> for mobile
一個月前我問過這個問題: 我正在嘗試將 <button> 放入 <input type="radio"> 的 <label>
我標記為正確的答案非常有效......對於我測試的桌面瀏覽器。 在我的 iPhone 6 上測試,Safari 和 Chrome 的按鈕都無法點擊。
正確答案片段復制如下:
button { pointer-events:none; }
<h1>Choose A or B</h1> <input type="radio" name="choice" value="A" id="a"><label for="a"><button type="button">A</button></label> <input type="radio" name="choice" value="B" id="b"><label for="b"><button type="button">B</button></label>
是否有適用於智能手機和台式機的解決方案?
我可以擺脫<input type=“radio”>
並從頭開始重寫 JavaScript 中的單選按鈕行為,但我希望我不需要這樣做。 有更容易的方法嗎?
<h1>Choose A or B</h1> <label> <input type="radio" name="mode" value="create"> <span style="-webkit-appearance: button;">create table</span> </label> <label> <input type="radio" name="mode" value="create"> <span style="-webkit-appearance: button;">create field</span> </label>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.