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!