我使用此代碼複選框選中事件,但它不起作用。自舉開關檢查事件?
CSS
<link href="assets/plugins/bootstrap-switch/static/stylesheets/bootstrap-switch-metro.css" rel="stylesheet" type="text/css" />
HTML
<div class="switch switch-mini" data-on-label="<i class='icon-sun icon-white'></i>" data-off-label="<i class='icon-sun muted'></i>">
<input id="swWeather" type="checkbox" class="toggle" onclick="toggleWeather()" />
</div>
JS
<script src="assets/plugins/bootstrap-switch/static/js/bootstrap-switch.js" type="text/javascript"></script>
如果我用這種方式,只是視覺的工作作風良好,但它不會觸發toggleWeather()
功能,但如果我刪除bootstrap-switch.js
,所有視覺樣式都被刪除,並且看起來像標準一樣dard複選框,雖然它工作得很好。
如何更改複選框檢查狀態用bootstrap-switch單擊它?
這裏我toggleweather代碼:
function toggleWeather() {
if (document.getElementById('swWeather').checked)
{ weatherLayer.setMap(map); }
else
{ weatherLayer.setMap(null); }
if (document.getElementById('swCloud').checked)
{ cloudLayer.setMap(map); }
else
{ cloudLayer.setMap(null); }
}
由我使用這些開關本主題的方式: http://www.keenthemes.com/preview/metronic_admin/form_component.html#myModal
這不是很好的例子,但像 http://jsfiddle.net/UHkN6/
郵政'toggleWeather'代碼在這裏,或使問題的小提琴在http://jsfiddle.net/ –
嘗試$(文件)。在( '點擊',」 #swWeather」,函數(){});對於點擊事件中的點擊事件 – V31
? 我必須穿上它嗎? – user2784250