The js time control only displays the year and month.

Source: Internet
Author: User
This article describes in detail how to display only the year and month in the js time control. It has a certain reference value. Let's take a look at the small series below. Let's not talk much about it. Please refer to the Code:

Initialize and load the db tag.

$ (Function () {$ ('# db '). datebox ({onShowPanel: function () {// displays the selected object and then triggers the event at the month layer. No month layer span is generated during initialization. trigger ('click'); // trigger the click event to bring up the if (! Tds) setTimeout (function () {// time delay triggered to obtain the month object, because the above event trigger and object generation have time interval tds = p. find ('p. calendar-menu-month-inner td '); tds. click (function (e) {e. stopPropagation (); // disable bubbling. Execute the event var year =/\ d {4}/.exec(span.html () [0] // to get the year, month = parseInt ($ (this ). attr ('abbr '), 10); // month. You do not need to add more than 1 $ (' # db') here '). datebox ('hidemopanel ') // hides the date object. datebox ('setvalue', year + '-' + month); // set the date value}) ;}, 0); yearIpt. unbind (); // Unbind any events in the year input box}, parser: function (s) {if (! S) return new Date (); var arr = s. split ('-'); return new Date (parseInt (arr [0], 10), parseInt (arr [1], 10)-1, 1);}, formatter: function (d) {return d. getFullYear () + '-' + (d. getMonth () + 1) ;}}); var p =$ ('# db '). datebox ('panel '), // Date select object tds = false, // Date select object month yearept = p. find ('input. calendar-menu-year '), // year input box span = p. find ('span. calendar-text '); // display the trigger control of the month layer });

Click to display and obtain the value of only the year, left for the emergency.

The above is all the content of this article. I hope this article will help you in your study or work, and I also hope to support PHP!

For more js time controls, only related articles of the year and month are displayed!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.