如何在jQuery Datepicker中添加一个类(How to add a class in jQuery Datepicker)

编程入门 行业动态 更新时间:2024-10-27 14:22:27
如何在jQuery Datepicker中添加一个类(How to add a class in jQuery Datepicker)

我的Web App中有一个DatePicker jQuery日历。 此时更改为上一个月或下个月的箭头是“透明的”。 但是,我意识到它是有效的,因为如果我点击“箭头”月份的变化。

我在Developper Tool上尝试了以下代码,它可以工作:

$('.ui-datepicker-next span').addClass('ui-btn ui-corner-all ui-icon-arrow-r ui-btn-icon-notext ui-alt-icon ui-nodisc-icon'); $('.ui-datepicker-prev span').addClass('ui-btn ui-corner-all ui-icon-arrow-l ui-btn-icon-notext ui-alt-icon ui-nodisc-icon');

如何在mi代码中添加此代码示例? 我试图将它包含在“beforeShow”方法中,但它不起作用。

有人想知道图标吗?

谢谢!!

I have a DatePicker jQuery calendar in my Web App. The arrows which change to the previous or the next month are 'transparent' at the moment. However, I realised that it works beacause if I click on the "arrow" the month changes.

I've tried the following code on the Developper Tool and it works:

$('.ui-datepicker-next span').addClass('ui-btn ui-corner-all ui-icon-arrow-r ui-btn-icon-notext ui-alt-icon ui-nodisc-icon'); $('.ui-datepicker-prev span').addClass('ui-btn ui-corner-all ui-icon-arrow-l ui-btn-icon-notext ui-alt-icon ui-nodisc-icon');

How can I add this code sample in mi code? I've tried to include it on the "beforeShow" method but it doesn't work.

Have someone any idea to show the icons?

Thanks!!

最满意答案

如果你的图标没有正确显示,可能是因为你遗漏了像css样式这样的东西。

无论如何,回答你的问题,如果你想要做的是在beforeShow打开后添加这些clases,你可以在你的beforeShow方法中添加一个小延迟,如下所示:

setTimeout(function() { $('.ui-datepicker-next span').addClass('ui-btn ui-corner-all ui-icon-arrow-r ui-btn-icon-notext ui-alt-icon ui-nodisc-icon'); $('.ui-datepicker-prev span').addClass('ui-btn ui-corner-all ui-icon-arrow-l ui-btn-icon-notext ui-alt-icon ui-nodisc-icon'); }, 500);

这将在500ms之后添加类,这足以让jquery生成datepicker

If your icons are not being displayed properly it's probably because you are missing something like the css styles.

Anyway, answering to your question, if what you want to do is add those clases after the datepicker has opened, you can add a small delay in your beforeShow method like the following:

setTimeout(function() { $('.ui-datepicker-next span').addClass('ui-btn ui-corner-all ui-icon-arrow-r ui-btn-icon-notext ui-alt-icon ui-nodisc-icon'); $('.ui-datepicker-prev span').addClass('ui-btn ui-corner-all ui-icon-arrow-l ui-btn-icon-notext ui-alt-icon ui-nodisc-icon'); }, 500);

That will add the classes after 500ms which will be enough for jquery to generate the datepicker

更多推荐

本文发布于:2023-08-05 22:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1440099.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   jQuery   Datepicker   add   class

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!