html:

<input type="text" id="datetime" >

js:

<script type="text/javascript">
$(function() {
$('#date').datebox({
onShowPanel : function() {// 显示日趋选择对象后再触发弹出月份层的事件,初始化时没有生成月份层
span.trigger('click'); // 触发click事件弹出月份层
if (!tds)
setTimeout(function() {// 延时触发获取月份对象,因为上面的事件触发和对象生成有时间间隔
tds = p.find('div.calendar-menu-month-inner td');
tds.click(function(e) {
e.stopPropagation(); // 禁止冒泡执行easyui给月份绑定的事件
var year = /\d{4}/.exec(span.html())[0]// 得到年份
, month = parseInt($(this).attr('abbr'), 10) + 1; // 月份
$('#date').datebox('hidePanel')// 隐藏日期对象
.datebox('setValue', year + '-' + month); // 设置日期的值
});
}, 0);
},
parser : function(s) {// 配置parser,返回选择的日期
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) {
var month = d.getMonth();
if(month<=10){
month = "0"+month;
}
if (d.getMonth() == 0) {
return d.getFullYear()-1 + '-' + 12;
} else {
return d.getFullYear() + '-' + month;
}
}// 配置formatter,只返回年月
});
var p = $('#date').datebox('panel'), // 日期选择对象
tds = false, // 日期选择对象中月份
span = p.find('span.calendar-text'); // 显示月份层的触发控件

});

</script>

easyui时间框只选择年月的更多相关文章

  1. easyui datebox 只选择年月

    //将日期输入框变为年月的函数方法    var month=0;      $('#effectiveDate').datebox({        onShowPanel: function () ...

  2. easyui的datebox只显示年月

    要求点击easyui的datebox时只显示年月,隐藏日,之前百度了好多,发现有的好麻烦,有的使用没效果,也许自己没理解,改不了.最后老员工帮我搞定了,添加一个fomatter和一个parser函数就 ...

  3. easyui datebox 扩展 只显示年月

    http://blog.csdn.net/zhaobao110/article/details/47755445 一个日期控件只显示年月是很正常的事情.可是easyui datebox 不支持这种格式 ...

  4. Android DatePickerDialog 只选择年月

    //对EditText注册OnTouch事件etSscxNssbDate.setOnTouchListener(selectDateTouchListener); //选择日期 private OnT ...

  5. DatePickerDialog 控制只选择年月或年或月

    etXyLevelDate.setOnTouchListener(selectDateTouchListener()); /** * @desc 选择日期操作 * @param @return * @ ...

  6. 玩转控件:重绘DEVEXPRESS中DateEdit控件 —— 让DateEdit支持只选择年月 (提供源码下载)

      前言 上一篇博文<玩转控件:重绘ComboBox —— 让ComboBox多列显示>中,根据大家的回馈,ComboBox已经支持筛选了,更新见博文最后最后最后面.   奇葩 这两天遇到 ...

  7. JavaScript-自制日历控件(只选择年月)

    <style> *{margin: 0px; padding: 0px;} </style> <input type="text" name=&quo ...

  8. jquery-weui picker组件实现只选择年月

    var date = new Date() var month = date.getMonth()+1 //获取当前月份 $('#selectTime').picker({ toolbarTempla ...

  9. bootstrap的datetimepicker控件只选择年月的配置

    <script src="{% static "jquery/jquery-1.11.3.min.js" %}"></script> & ...

随机推荐

  1. git 多用户多仓库配置

    ssh全称是Secure Shell,即安全Shell,是一种可以进行安全远程登录的协议,在Linux中以OpenSSH为代表,Windows中则有Putty作为实现.ssh的会话建立阶段类似TCP协 ...

  2. Python爬虫爬取网页图片

    没想到python是如此强大,令人着迷,以前看见图片总是一张一张复制粘贴,现在好了,学会python就可以用程序将一张张图片,保存下来. 今天逛贴吧看见好多美图,可是图片有点多,不想一张一张地复制粘贴 ...

  3. remote: Permission to user_name/Code.git denied to other_user_name. fatal: unable to access 'https://github.com/user_name/Code.git/': The requested URL returned error: 403

    Error msg: $ git push remote: Permission to xxx/Code.git denied to xxxxxx. fatal: unable to access ' ...

  4. (light oj 1102) Problem Makes Problem (组合数 + 乘法逆元)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1102 As I am fond of making easier problems, ...

  5. iOS App上架流程(2016详细版)来源DeveloperLY

    一.前言: 作为一名iOSer,把开发出来的App上传到App Store是必要的.下面就来详细讲解一下具体流程步骤. 二.准备: 一个已付费的开发者账号(账号类型分为个人(Individual).公 ...

  6. centos下安装Vmware-tools时出现的问题

    今天装了centos,想共享一个文件,需要安装Vmware-tools. 正常的步骤: 安装Vmware-tools 1.挂载VMwareTools光驱.虚拟机选项栏中选[虚拟机]-->[安装v ...

  7. 'python'不是内部或外部命令,也不是可运行程序或批处理文件

    配置两个环境变量: 我的电脑——属性——高级系统设置——环境变量——用户变量——path(新建) 1.配置python\python.exe所在的路径       path新建:C:\Users\Py ...

  8. 汉诺塔I && II

    汉诺塔I 题目链接:https://www.nowcoder.com/questionTerminal/7d6cab7d435048c4b05251bf44e9f185 题目大意: 略 分析: 利用汉 ...

  9. P5057 [CQOI2006]简单题

    题目描述 有一个 n 个元素的数组,每个元素初始均为 0.有 m 条指令,要么让其中一段连续序列数字反转——0 变 1,1 变 0(操作 1),要么询问某个元素的值(操作 2). 例如当 n = 20 ...

  10. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

     今天安装完带图形界面的CentOS 7后,在Terminal中运行yum安装命令时报了以下错误: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...