代码之家  ›  专栏  ›  技术社区  ›  jrummell

如何将jqueryui按钮图标添加到输入按钮?

  •  14
  • jrummell  · 技术社区  · 16 年前

    是否可以使用 jQuery UI Button icons 具有 <input type="submit"> 元素?

    文档示例使用 <button> < .

    这就是我尝试过的:

    $("input.add").button({ icons: { primary: "ui-icon-circle-plus" } });
    

    4 回复  |  直到 16 年前
        1
  •  11
  •   Bradley Mountford    15 年前

    <span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span> 但这似乎不会发生在输入元素上。

    if ( this.type === "input" ) {
      if ( this.options.label ) {
        this.element.val( this.options.label );
      }
      return;
    }
    

    它基本上告诉代码在输入元素前面加上span/附加span之前退出。所以这是设计的。

        2
  •  11
  •   Cane    15 年前

    改变你的想法asp:Button to 一asp:LinkButton and 世界上一切都好。是的,真的很简单。

        3
  •  1
  •   Mantas VaitkÅ«nas    14 年前

    我的问题是覆盖样式,所以这个解决方案帮助了我:

    $('input.add').each(function(){
              $(this).replaceWith('<button  class="add" type="' + $(this).attr('type') + '">' + $(this).val() + '</button>');
    });
    $('.add').button({ icons: { primary: 'ui-icon-circle-plus' } });
    
        4
  •  1
  •   FábioMuniz    13 年前

    我正在寻找这个解决方案,我发现我的一个完美的工作

    javascript语言

    $(function () {
    
        //botoes de login
    
        $("#btnLogin").button({
                icons: { primary: "ui-icon-key" }
            }).hide().after('<button>').next().button({
                icons:
                {
                    primary: 'ui-icon-key'
                },
                label: $("#btnLogin").val()
            }).click(function (event) {
                event.preventDefault();
                $(this).prev().click();
            });
        $("#close").button({ icons: { primary: "ui-icon-close" } });
    });
    

    <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />