jQuery 单击时如何使用 Bootstrap 按钮显示动画 gif
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18568792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show animated gif using Bootstrap button when clicked
提问by Thomas
i know how to show loading... text when user click on Bootstrap button. this way i do it
我知道如何在用户单击 Bootstrap 按钮时显示正在加载...文本。我这样做
add two dependency files
1) bootstrap.min.css
2) bootstrap.min.js
<button class="btn" id="button" data-text-loading="Loading...">Press Me</button>
$('#button').button();
$('#button').click(function() {
$(this).button('loading');
});
now how could i show this animated gif http://www.bba-reman.com/images/fbloader.gifat the place of button when user will click on button.
现在我如何在用户单击按钮时在按钮位置显示此动画 gif http://www.bba-reman.com/images/fbloader.gif。
please guide me how to do with sample code if possible. thanks
如果可能,请指导我如何处理示例代码。谢谢
回答by Alvaro
What about this:
那这个呢:
$('#button').button();
$('#button').click(function() {
$(this).html('<img src="http://www.bba-reman.com/images/fbloader.gif" />');
});
Living demo: http://jsfiddle.net/YCst4/857/
回答by Artyom Neustroev
回答by edotassi
$('#button').click(function() {
$(this).replaceWith('<img src="[loader-url]" />');
});