2
我試圖創建一個使用自舉3個切換和我加了一些if語句,他們中的一些工作,但其餘的都沒有工作引導切換和if語句
這是我的完整代碼
<html>
<head>
<title>Bootstrap Form Helpers Basic Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<h1>Hello, world!</h1>
<input id="toggle-email" checked type="checkbox" data-toggle="toggle" data-on="<i class='glyphicon glyphicon-ok'></i> Email On" data-off="<i class='glyphicon glyphicon-remove'></i> Email OFF" data-onstyle="success" data-offstyle="danger" data-width="150">
<input id="toggle-phone" type="checkbox" data-toggle="toggle" data-on="<i class='glyphicon glyphicon-ok'></i> Phone On" data-off="<i class='glyphicon glyphicon-remove'></i> Phone OFF" data-onstyle="success" data-offstyle="danger" data-width="150">
<br>
<br>
<input id="toggle-both" type="checkbox" data-toggle="toggle" data-on="<i class='glyphicon glyphicon-ok'></i> Email & Phone On" data-off="<i class='glyphicon glyphicon-remove'></i> Email & Phone OFF" data-onstyle="success" data-offstyle="danger" data-width="300">
<script>
\t
\t
\t
\t $(function() {
\t \t
\t \t
\t \t $("#toggle-email").on("change", function() {
\t \t \t if (this.checked) {
\t \t \t \t $('#toggle-phone').bootstrapToggle('off');
\t \t \t \t $('#toggle-both').bootstrapToggle('off');
\t \t \t }
\t \t \t else{
\t \t \t \t $('#toggle-phone').bootstrapToggle('on');
\t \t \t \t $('#toggle-both').bootstrapToggle('off');
\t \t \t }
\t \t })
\t \t
\t \t $("#toggle-phone").on("change", function() {
\t \t \t if (this.checked) {
\t \t \t \t $('#toggle-email').bootstrapToggle('off');
\t \t \t \t $('#toggle-both').bootstrapToggle('off');
\t \t \t }
\t \t \t else{
\t \t \t \t $('#toggle-email').bootstrapToggle('on');
\t \t \t \t $('#toggle-both').bootstrapToggle('off');
\t \t \t }
\t \t })
\t \t
\t \t $("#toggle-both").on("change", function() {
\t \t \t if (this.checked) {
\t \t \t \t $('#toggle-email').bootstrapToggle('on');
\t \t \t \t $('#toggle-phone').bootstrapToggle('on');
\t \t \t }
\t \t \t else{
\t \t \t \t $('#toggle-email').bootstrapToggle('on');
\t \t \t \t $('#toggle-phone').bootstrapToggle('off');
\t \t \t \t
\t \t \t }
\t \t })
\t \t
\t \t
\t \t
\t \t
\t });
\t
\t
</script>
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
</body>
</html>
的if語句清晰和易於理解我的觀點
有什麼建議?
謝謝
非常感謝,它現在正在工作!我對javascript和jquery的知識非常低,但我正在使用python燒瓶,並希望添加此功能,再次感謝 –