jquery ui datepicker 按钮的类 [英] class for jquery ui datepicker button

查看:11
本文介绍了jquery ui datepicker 按钮的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have the following code for the jQuery UI datepicker:

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

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

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?

推荐答案

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

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:

.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");
});

这篇关于jquery ui datepicker 按钮的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆