引入css
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> <link href="http://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/build.css">
<script type="text/javascript">
function changeState(el) {
if (el.readOnly) el.checked=el.readOnly=false;
else if (!el.checked) el.readOnly=el.indeterminate=true;
}
</script>我发现了一个bug,就是这样的代码片段如果把第一个单选按钮的checked去掉,所有单选按钮都会变成选中状态,且勾变成了一条横线,难道只有我看出来吗?代码如下:
<div class="checkbox checkbox"> <input type="radio" name="radio4" id="radio7" value="option1" checked> <label for="radio7"> Default </label> </div> <div class="checkbox checkbox-success"> <input type="radio" name="radio4" id="radio8" value="option2"> <label for="radio8"> Success </label> </div> <div class="checkbox checkbox-danger"> <input type="radio" name="radio4" id="radio9" value="option3"> <label for="radio9"> Danger </label> </div>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link href="http://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/build.css">
</head>
<body>
<input type="radio" class="radio-primary" name="a1" onclick="changeState(this)" />11
<input type="radio" class="radio-primary" name="a1" onclick="changeState(this)" />12
<script type="text/javascript">
function changeState(el) {
if (el.readOnly) el.checked = el.readOnly = false;
else if (!el.checked) el.readOnly = el.indeterminate = true;
}
</script>
</body>我想问下为什么没效果?
我用了一下 他有两个勾?