問題描述
如何設置單選按鈕的樣式,使其看起來像普通的可點擊按鈕? (How do I style a radio button to look like a normal clickable button?)
我正在嘗試讓我的單選按鈕看起來像普通按鈕 ‑ 我該怎麼做?我已經看到了很多關於此的其他問題,但我無法得到明確的答案。這是我嘗試過的:
<input name="question${questionNumber}" id="q&a" class="press" type="radio" value="${letter}"><label for="q&a">${letter}</label>
但是,我的 javascript 代碼沒有記錄它,我仍然需要單擊 javascript 的單選按鈕才能識別我點擊了按鈕,只有當我點擊單選按鈕時才能找到它的值。我該如何解決這個問題?
參考解法
方法 1:
Why use a radio button at all if you want it to look like a normal button? Radio buttons are for selecting 1 option out of many, like in a multiple‑choice test. Their design reflects this purpose and most people know how to interact with radio buttons when they see them. If you use a normal button, you can use
Element.addEventListener(“click” function() {
// do your stuff
})