javascript - 如何自动关闭切换按钮

标签 javascript jquery css html 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();
    }
};

最佳答案

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

最初 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();
 }
}); 

关于javascript - 如何自动关闭切换按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21549873/

相关文章:

javascript - 有没有办法简化这个jquery?

javascript - 将外部文件加载到 html 时如何保留搜索引擎的可访问性

使用 D3.js 时 DataTables 中的 Javascript 错误

html - 如何向图像添加提交操作

javascript - 从 Firebase Cloud Function 中的 equalTo 返回空结果

javascript - 如何使当前元素切换,而不是让所有元素切换

javascript - 如何在 JavaScript 中打印呈现的 HTML 页面的一部分?

html - 我可以将直接后代与第一个 child 伪选择器结合起来吗?

php - 如果数据错误,更改输入的背景颜色

javascript - 将关系查询数据添加到主 JSON 结果