Html代码:
var td5 = document.createElement("TD")
var strHtml5 = "<From><INPUT Id=\"one\" CLASS=\"datepicker\" type=\"Text\" readonly=\"true\">";
td5.innerHTML = strHtml5.replace(/!count!/g,count);
var td6 = document.createElement("TD")
var strHtml6 = "<To><INPUT Id=\"two\" CLASS=\"datepicker\" type=\"Text\" readonly=\"true\">";
td6.innerHTML = strHtml6.replace(/!count!/g,count);
这是日期选择器功能
$(function() {
$('input').filter('.datepicker').datepicker({
changeMonth: true,
changeYear: true,
depth: "year",
showOn: 'both',
buttonImage:'../../resources/theme1/image/calendar.png',
buttonImageOnly: true,
disabled: true,
});
});
答案 0 :(得分:0)
您可以将
datepicker
初始化对象存储为全局变量,并且可以在以后添加新的datepicker
元素时使用它。
试试这个:
//GLOBAL_INIT will hold the initialization in global context to be used later
var GLOBAL_INIT = {
changeMonth: true,
changeYear: true,
depth: "year",
showOn: 'both',
buttonImage: '../../resources/theme1/image/calendar.png',
buttonImageOnly: true,
disabled: true,
};
var td5 = document.createElement("TD")
var strHtml5 = "<From><INPUT Id=\"one\" CLASS=\"datepicker\" type=\"Text\" readonly=\"true\">";
td5.innerHTML = strHtml5.replace(/!count!/g, count);
var td6 = document.createElement("TD")
var strHtml6 = "<To><INPUT Id=\"two\" CLASS=\"datepicker\" type=\"Text\" readonly=\"true\">";
td6.innerHTML = strHtml6.replace(/!count!/g, count);
//Will initialize when elements are appended
$(strHtml5).datepicker(GLOBAL_INIT);
$(strHtml6).datepicker(GLOBAL_INIT);
//Will initialize `'.datepicker'` elements initially
$(function() {
$('input').filter('.datepicker').datepicker(GLOBAL_INIT);
});
&#13;