禁用jquery上的单选按钮
我想通过双击单选按钮的相同元素来实现清除选择的选项。但我不明白禁用jquery上的单选按钮,jquery,Jquery,我想通过双击单选按钮的相同元素来实现清除选择的选项。但我不明白 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="https://stackpath.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap
.min.css">
</head>
<body>
<div class="col">
<div class="btn-group btn-group-toggle" >
<label class="btn btn-outline-primary">
<input type="radio" >1</label>
<label class="btn btn-outline-primary">
<input type="radio" > 2</label>
<label class="btn btn-outline-primary" >
<input type="radio" > 3</label>
</div>
<br>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/
umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/
bootstrap.min.js"></script>
<script >
$('.btn-group').on('click', '.btn', function() {
$(this).addClass('active').siblings().removeClass('active');
});
在此处插入标题
1.
2.
3.
$('.btn group')。在('单击','.btn',函数()上{
$(this.addClass('active').sides().removeClass('active');
});
像这样的事
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>
<body>
<div class="col">
<div class="btn-group btn-group-toggle" ><label class="btn btn-outline-primary"><input type="radio" >1</label><label class="btn btn-outline-primary"><input type="radio" > 2</label><label class="btn btn-outline-primary" ><input type="radio" > 3</label></div>
<br>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/ umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/ bootstrap.min.js"></script>
<script>// Single click - Select and deselect all buttons
$('.btn').click(function(){
$('.btn').removeClass('active');
$(this).addClass('active');
});
// Double click - Deselect button
$('.btn').dblclick(function(){
$(this).removeClass('active');
});
</script>
</body>
</html>
在此处插入标题
1 2 3
//单击-选择并取消选择所有按钮
$('.btn')。单击(函数(){
$('.btn').removeClass('active');
$(this.addClass('active');
});
//双击-取消选择按钮
$('.btn').dblclick(函数(){
$(this.removeClass('active');
});
使用click和dblclick方法 像这样的
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>
<body>
<div class="col">
<div class="btn-group btn-group-toggle" ><label class="btn btn-outline-primary"><input type="radio" >1</label><label class="btn btn-outline-primary"><input type="radio" > 2</label><label class="btn btn-outline-primary" ><input type="radio" > 3</label></div>
<br>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/ umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/ bootstrap.min.js"></script>
<script>// Single click - Select and deselect all buttons
$('.btn').click(function(){
$('.btn').removeClass('active');
$(this).addClass('active');
});
// Double click - Deselect button
$('.btn').dblclick(function(){
$(this).removeClass('active');
});
</script>
</body>
</html>
在此处插入标题
1 2 3
//单击-选择并取消选择所有按钮
$('.btn')。单击(函数(){
$('.btn').removeClass('active');
$(this.addClass('active');
});
//双击-取消选择按钮
$('.btn').dblclick(函数(){
$(this.removeClass('active');
});
使用click和dblclick方法 哇,谢谢你,伙计。你能一次点击取消选择一个吗?我会非常感激哇谢谢你,伙计。你能一次点击取消选择一个吗?我将非常感激