【发布时间】:2013-10-19 03:24:42
【问题描述】:
我正在尝试使用引导按钮切换背景图像。
我在 css...
body {
background-image: url('img/myimage_1.gif');
}
在 html 中...
<button type="button" id="bkgchange" class="btn" data-toggle="button">Change the background</button>
在脚本中...
$( 'bkgchange' ).click(function() {
$( #body ).css( 'background-image', '~/img/myimage_2.gif' );
});
它不工作?!任何指针。我知道想要弄乱 body 属性是非常规的,我不能将图像作为 div 背景或容器中,因为它本身不会表现...
替代方案与直接解决方案一样受欢迎。
【问题讨论】:
标签: jquery css twitter-bootstrap button background