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

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

问题描述

对于jQuery UI datepicker,我具有以下代码:

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天全站免登陆