如何制作bootstrap单选按钮(aspx)

时间:2017-08-23 12:43:14

标签: html asp.net twitter-bootstrap

我正在尝试制作一种个人资料页面。我希望用户能够从3个主题中进行选择(它只会改变网站上页面的颜色)。但是,当单击单选按钮时,我不知道如何制作它。 这是我的代码:



<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel-body">
  <div class="container">
     <form>
        <div class="radio">
            <label>
                <input type="radio" name="optradio">Blue
            </label>
        </div>
        <div class="radio">
            <label>
                <input type="radio" name="optradio">Red                  
            </label>
        </div>
        <div class="radio disabled">
            <label>
                <input type="radio" name="optradio">Wood
            </label>
        </div>
      </form>
      </div>
  </div>
</div>
&#13;
&#13;
&#13;

问题是:如何使单选按钮实际执行某些操作? 编辑:我的坏,我想使用实际的单选按钮而不是按钮。我删除了上面的代码并替换了它。

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
function red() {
    document.getElementById("he").style.backgroundColor = "red";
}
        function blue() {
    document.getElementById("he").style.backgroundColor = "blue";
}
        function green() {
    document.getElementById("he").style.backgroundColor = "green";
}
&#13;
<body id="he">
  <div class="panel-body">
      <div class="container">
       <form>
         <div class="radio" >
           <label>
            <input type="radio" name="optradio" onclick="blue();">Blue</label>
         </div>
         <div class="radio">
           <label>
            <input type="radio" name="optradio" onclick="red();">Red</label>
         </div>
         <div class="radio">
         <label>
           <input type="radio" name="optradio" onclick="green();">Green</label>
         </div>
         </form>
        </div>
    </div>
</body>
&#13;
&#13;
&#13;

这就是你正在寻找的东西吗?