开发者

Add The same button-ui icons to the different buttons with unique IDS

I have a series of buttons and some share the same icons. Presently I'm doing:

        $("#addNewSt开发者_运维百科ory").button({icons: {primary: 'ui-icon-plus'}});
    $("#addNewCampaign").button({icons: {primary: 'ui-icon-plus'}});
    $("#addNewAdItem").button({icons: {primary: 'ui-icon-plus'}});

Is there a neater way?

Thx


In the general case, if you want to make all elements having id "addNewXXX" to have that button, you could use

        $("[id^='addNew']").button({icons: {primary: 'ui-icon-plus'}});


You can do multiple selectors in the same statement

$("#addNewStory, #addNewCampaign, #addNewAdItem").button({icons: {primary: 'ui-icon-plus'}});


OK, sorry, should have tried it first. Solution was just:

$("#addNewStory, #addNewCampaign, #addNewAdItem").button({icons: {primary: 'ui-icon-plus'}});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜