如何将类添加到链接中的按钮

时间:2014-07-14 09:12:12

标签: jquery

我想在以下链接中更改按钮和工具提示的现有类。我怎么能这样做?

 $("<a>")
              .attr("tabIndex", -1)
              .attr("title", "Show All Items")
              .tooltip(   //change class here)
              .appendTo(this.wrapper)
              .button({
                        //change class here
              })
              .removeClass("ui-corner-all")
              .addClass("custom-combobox-toggle")
              .mousedown(function () {
                  wasOpen = input.autocomplete("widget").is(":visible");
              })

.ButtonStyle { background-image: url('../Arrow_Down.gif'); margin: 0; border: outset; height: 22px; width: 20px; padding: 0; }

目前,呈现的HTML如下:请注意我想要更改它。

enter image description here

2 个答案:

答案 0 :(得分:1)

添加类使用:

buttonObj.addClass('class');

并改变任何类的风格:

$('.tooltip').css({/* new css values*/});
如果你表现出一些小提琴或类似的东西,那就更好了。

答案 1 :(得分:0)

假设你的html是这样的:

<form action="http://google.com">
    <input id="fooButton" type="submit" value="click me">
</form>

您的查询将是:

$('#fooButton').on('click', function() {
  $(this).addClass('fooClass');
});
相关问题