Change the icon of a jQuery UI button with own image

后端 未结 7 1706
慢半拍i
慢半拍i 2020-12-10 01:31

Currently I have the following jQuery UI button:

$(\'#button\').button(
  {
    label: \'Test\',
    icons: {primary: \'ui-icon-circle-plus\', secondary: nul         


        
7条回答
  •  星月不相逢
    2020-12-10 01:55

    Take a look at Nick Craver's comment. I tried his answer it exactly as is, but it still didn't help me. The issue (I assume) was that the ui-icon-custom class was at the end of the class list, and didn't seem to override it to original ui-icon class background image.

    What I did to get it to work was add !important to the end of the icon css like so

    .ui-icon-custom { background-image: url(images/custom.png) !important; }
    

    You might have to change the height and width properties, but this worked for me.

提交回复
热议问题