开发者

class for jquery ui datepicker button

I have the following code for the jQuery UI datepicker:

$(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?


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


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

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

Disclaimer: My Blog

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜