开发者

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

开发者 https://www.devze.com 2023-01-15 06:08 出处:网络
I have a series of buttons and some share the same icons. Presently I\'m doing: $(\"#addNewSt开发者_运维百科ory\").button({icons: {primary: \'ui-icon-plus\'}});

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

精彩评论

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