Bootstrap 3中的加载状态按钮 [英] Loading state button in Bootstrap 3

查看:269
本文介绍了Bootstrap 3中的加载状态按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Bootstrap 3的新手.无法弄清楚如何激活加载状态按钮功能.下面的代码来自 getboostrap.com 上的文档.

I'm new to Bootstrap 3. Can't figure out how to activate the loading state button function. My code below is from the documents on getboostrap.com.

<button type="button" data-loading-text="Loading..." class="btn btn-primary">
  Loading state
</button>

下拉菜单工作正常,所以我想问题出在其他地方吗?

Dropdowns works fine so I guess the problem is somewhere else?

推荐答案

您需要从JS端检测点击,您的HTML保持不变. 注意:此方法自v3.5.5起已弃用,并已在v4中删除.

You need to detect the click from js side, your HTML remaining same. Note: this method is deprecated since v3.5.5 and removed in v4.

$("button").click(function() {
    var $btn = $(this);
    $btn.button('loading');
    // simulating a timeout
    setTimeout(function () {
        $btn.button('reset');
    }, 1000);
});

此外,别忘了在页面中加载jQuery和Bootstrap js(基于jQuery)文件.

Also, don't forget to load jQuery and Bootstrap js (based on jQuery) file in your page.

JSFIDDLE

官方文档

这篇关于Bootstrap 3中的加载状态按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆