【问题标题】:How to add jquery button style to make background icon transparent如何添加jquery按钮样式以使背景图标透明
【发布时间】:2012-11-15 16:31:56
【问题描述】:

我有解决方案,如果我把它放在标记中,它就可以正常工作:

//class="ui-icon ui-icon-closethick" title="Close all" style="cursor:pointer;background-image: url(content/jquery/jquery-ui/1.8.21/css/ui-lightness/images/ui-icons_ffffff_256x240.png);"

但是我需要在下面的代码中添加所有这些信息,但我找不到正确的 sintax:

$(objID).button
    ({
        icons:
        {
          primary: "ui-icon-closethick { margin:10px; }",
        },
        text: false
    }).click(function() {
            alert("Clicked!");
    });
}

感谢任何帮助

【问题讨论】:

  • 天哪,我什至不知道这意味着什么...只是使用论坛获得一些帮助...无论如何谢谢
  • 如果对您有帮助,您可以接受旧问题中的答案。这样,帮助您的人会获得一点声誉,而有些人更有可能为此提供帮助。请务必在stackoverflow.com/faq 中阅读此 论坛 的工作原理

标签: jquery jquery-ui jquery-widgets


【解决方案1】:

只需将样式放在一个类中并在点击事件中使用.addClass()..

.button
{
   cursor:pointer;
   background-image: url(content/jquery/jquery-ui/1.8.21/css/ui-lightness/
                         images/ui-icons_ffffff_256x240.png);
}

.click(function() {
            alert("Clicked!");
           $(this).addClass('button');
    });

【讨论】:

  • 那不起作用:(另外,当我调用那部分代码时,我需要将图像绑定到按钮,而不是当我单击按钮时。感谢您的回复。
  • 越来越近,指针可以工作,但图像不会显示:... var header = "" ... span.CloseAllWindowsButton { cursor:pointer;背景图像:url(内容/jquery/jquery-ui/1.8.21/css/ui-lightness/images/ui-icons_ffffff_256x240.png); } //TO DO:检查为什么没有应用背景图像/正在应用光标 $(objID).addClass('CloseAllWindowsButton');
猜你喜欢
  • 2023-03-06
  • 2015-02-22
  • 2011-05-19
  • 2022-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多