jquery ui datepicker 按钮的类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3929600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:22:03  来源:igfitidea点击:

class for jquery ui datepicker button

jqueryjquery-uidatepicker

提问by Doug Barrett

I have the following code for the jQuery UI datepicker:

我有以下用于 jQuery UI 日期选择器的代码:

$(function() {
        $(".date").datepicker({
            showOn: 'button',
            buttonText: "Choose Date",
            dateFormat: 'yy-mm-dd'
        });
    });

It creates a button on the side of the text box so people can click the box and select a date. Is it possible to apply a class to the button that is created so I can apply a CSS style to it?

它会在文本框的一侧创建一个按钮,以便人们可以单击该框并选择一个日期。是否可以将类应用于创建的按钮,以便我可以对其应用 CSS 样式?

回答by Nick Craver

You can't add an additional class through an option, but it does have a class: ui-datepicker-trigger, so if you just style directly or as a descendant of an identifiable container it'll work, for example:

您不能通过选项添加额外的类,但它确实有一个 class: ui-datepicker-trigger,因此如果您只是直接设置样式或作为可识别容器的后代,它将起作用,例如:

.ui-datepicker-trigger { color: red; }
//or...
.myContainer .ui-datepicker-trigger { color: red; }

Or, add a different class to the button manually after creating the datepicker (which creates the button):

或者,在创建日期选择器(创建按钮)后手动向按钮添加不同的类:

$(function() {
    $(".date").datepicker({
        showOn: 'button',
        buttonText: "Choose Date",
        dateFormat: 'yy-mm-dd'
    }).next(".ui-datepicker-trigger").addClass("someClass");
});

回答by Mavelo

Make it become a jQuery UI button since you already have the framework loaded ;)

使它成为一个 jQuery UI 按钮,因为您已经加载了框架;)

http://www.robertmullaney.com/2011/08/26/make-jquery-datepicker-use-ui-button/

http://www.robertmullaney.com/2011/08/26/make-jquery-datepicker-use-ui-button/

Disclaimer: My Blog

免责声明:我的博客