首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery成功后无法更改按钮文本

问jQuery成功后无法更改按钮文本
EN

Stack Overflow用户
提问于 2017-04-28 18:56:53
回答 1查看 154关注 0票数 0

我试图更改按钮的文本,但我做不到。

​

代码语言:javascript
复制
$( function() {
 $('.btn').on('click', function(automated_campagin_hash) {
    var $this = $(this);
    $this.button('loading');
        
    var automated_campagin_hash = $this.data('campaign-automated-hash');
    var url = "/automated-campaigns/change_status/" + String(automated_campagin_hash);
    $.get( url , function( data ) {
          console.log(data);
        $this.button('reset');
        $this.removeClass("btn-danger").addClass("btn-info");
        $this.html('Activated');
    });
});
});
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<button type="button" class="btn btn-danger btn" id="load" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i>" data-campaign-automated-hash="<%= automated_campaigns[i].automated_campaign_hash %>">Desativar</button>

​

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-28 19:25:05

您提到了您也在使用引导(虽然它没有在您的代码片段中引用)。下面是引用自Another SO question的一个可能的解决方案

它是由jquery和引导按钮插件冲突引起的。事实上,jquery代码js代码应该放在bootstrap.js之前,这解决了问题。 只需将jquery插件放在bootstrap.js之前即可。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43687141

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档