【问题标题】:How to add text between two radio buttons of same group如何在同一组的两个单选按钮之间添加文本
【发布时间】:2022-01-04 17:46:41
【问题描述】:

我正在尝试创建一个选择,其中我有两个相同组的单选按钮和一些文本。就像单个正确的 MCQ...

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practice</title>
</head>
<body>
    <input type="radio"> This_1 <br> 
    or <br>
    <input type="radio"> This_2
</body>
</html>

现在我想要的是用户只能选择一个单选按钮。 但是,只要我在其间添加 OR,单选按钮就会分为两组。相反,我可以选择它们,你知道我在说什么...... 请帮助非常感谢。 非常感谢!!

【问题讨论】:

    标签: html web visual-web-developer


    【解决方案1】:

    你的意思是这样的吗?:

    <p>Select an option:</p>
    
    <div>
      <input type="radio" id="1" name="options" value="1"
             checked>
      <label for="huey">1</label>
    </div>
    
    <p>TEXT 1</p>
    
    <div>
      <input type="radio" id="2" name="options" value="2">
      <label for="dewey">2</label>
    </div>
    
    <p>TEXT 2</p>
    
    <div>
      <input type="radio" id="3" name="options" value="3">
      <label for="louie">3</label>
    </div>
    

    【讨论】: