It is normal for a date control to show only the month and year. However, Easyui Datebox does not support this format, or is to intercept the string, not desirable, I did not write a similar extension, but also is the implementation of the function, first of all to a picture bar
I can not write a level of advanced things, code, we are able to understand, but still contribute, let us make suggestions for common progress
$.extend ($.fn.combobox.methods, {
Yearandmonth:function (JQ) {
Return Jq.each (function () {
var obj = $ (this). ComboBox ();
var date = new Date ();
var year = Date.getfullyear ();
var month = Date.getmonth () + 1;
var table = $ (' <table> ');
var TR1 = $ (' <tr> ');
var tr1td1 = $ (' <td> ', {
Text: '-',
Click:function () {
var y = $ (this). Next (). HTML ();
y = parseint (y)-1;
$ (this). Next (). html (y);
}
});
Tr1td1.appendto (TR1);
var tr1td2 = $ (' <td> ', {
Text:year
}). appendTo (TR1);
var tr1td3 = $ (' <td> ', {
Text: ' + ',
Click:function () {
var y = $ (this). Prev (). html ();
y = parseint (y) + 1;
$ (this). Prev (). html (y);
}
}). appendTo (TR1);
Tr1.appendto (table);
var n = 1;
for (var i = 1; I <= 4; i++) {
var tr = $ (' <tr> ');
for (var m = 1; M <= 3; m++) {
var td = $ (' <td> ', {
Text:n,
Click:function () {
var yyyy = $ (table). Find ("Tr:first>td:eq (1)"). html ();
var cell = $ (this). html ();
var v = yyyy + '-' + (Cell.length < 2?) ' 0 ' + Cell:cell);
Obj.combobox (' SetValue ', V). ComboBox (' Hidepanel ');
}
});
if (n = = month) {
Td.addclass (' Tdbackground ');
}
Td.appendto (TR);
n++;
}
Tr.appendto (table);
}
Table.addclass (' mytable cursor ');
Table.find (' TD '). Hover (function () {
$ (this). addclass (' Tdbackground ');
}, function () {
$ (this). Removeclass (' Tdbackground ');
});
Table.appendto (Obj.combobox ("Panel"));
});
}
});
Call the method $ (' #id '). ComboBox (' Yearandmonth ')
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Easyui Datebox extensions only show the month