如何自动关闭切换按钮

时间:2014-02-04 10:30:02

标签: javascript jquery css html5 twitter-bootstrap

我想自动关闭按钮,无论我选择该产品应该关闭。当点击时,它应该显示该产品。

HTML

<div class="heading" id="seamless" style="display: none;">
   <center>PayPal now accepted! Make a sale and we'll email you to claim your funds. Easy!Your email: admin@example.com</center>
</div>

切换按钮

<div id="normal-toggle-button">
   <input name="open" value="1" type="checkbox" onchange="checkshowhidereverse(this.status, '#seamless');checkshowhidereverse(this.status, '#setup');" checked="checked" />
</div>

的Javascript

$(document).ready(function () {
   //* toggle buttons
   toggle_buttons.init();
});

Javascript功能

//* toggle buttons
toggle_buttons = {
    init: function () {
        $('#normal-toggle-button').toggleButtons();
    }
};

1 个答案:

答案 0 :(得分:0)

我不太确定我是否理解得很好?

最初隐藏DIV,未选中复选框?如果是的话怎么样

http://jsfiddle.net/8sCw8/

<div class="heading" id="seamless" style="display: none;">
<center>PayPal now accepted! Make a sale and we'll email you to claim your funds. Easy!Your email: admin@example.com</center>
</div>

<div id="normal-toggle-button">
<input id="checkBox" name="open" value="1" type="checkbox"/>
</div>

JS:

$('#checkBox').click(function() {
 if( $(this).is(':checked')) {
     $("#seamless").show();
 } else {
     $("#seamless").hide();
 }
}); 
相关问题