尝试在两个图标之间切换

发布于 2024-09-27 21:26:45 字数 313 浏览 2 评论 0原文

我启动两个按钮(我使用的是 CSS themeroller 中内置的 JQuery):

$( ".upArrow" ).button({ icons: {secondary:'ui-icon-circle-arrow-n'} });
$( ".downArrow" ).button({ icons: {secondary:'ui-icon-circle-arrow-s'} });

我希望在单击同一按钮时能够在这两个图标之间切换,并以某种方式在 .upArrow 类和 .downArrow 类之间切换。我不知道怎么办。我将不胜感激任何帮助。

I initiate two buttons (I'm using the JQuery built in CSS themeroller):

$( ".upArrow" ).button({ icons: {secondary:'ui-icon-circle-arrow-n'} });
$( ".downArrow" ).button({ icons: {secondary:'ui-icon-circle-arrow-s'} });

I want to be able to toggle between these two icons when clicking the same button, and somehow switch between the .upArrow class and .downArrow class. I'm not sure how. I'd appreciate any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

残花月 2024-10-04 21:26:46

由于您使用的是 jQuery UI 按钮,因此您可以更改 icon选项toggle()函数。

$('#button').toggle(function(){
    $(this).button('option', 'icons', {secondary:'ui-icon-circle-arrow-n'});
}, function(){
    $(this).button('option', 'icons', {secondary:'ui-icon-circle-arrow-s'});
});

Since you're working with jQuery UI buttons, you can change the icon option with the toggle() function.

$('#button').toggle(function(){
    $(this).button('option', 'icons', {secondary:'ui-icon-circle-arrow-n'});
}, function(){
    $(this).button('option', 'icons', {secondary:'ui-icon-circle-arrow-s'});
});
无名指的心愿 2024-10-04 21:26:46

您可以使用 jQuery 的 .toggleClass() 方法。您不一定需要删除其他类,只需使用 CSS 来覆盖其他类的设置即可:

$('#foo').toggleClass(className, addOrRemove);

You can use the .toggleClass() method of jQuery. You don't necessarily need to take away the other class, just use CSS to your advantage to override the other class' settings:

$('#foo').toggleClass(className, addOrRemove);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文