document.getElementById is not working.
,但我可以看到DOM中存在id="calendar1_dayId2017-07-17"
,即表:
<td class="dayNumber" id="calendar1_dayId2017-07-17"> <span class="otherDate">17</span> <span class="date" hidden="">2017-07-17</span></td>
$( document ).ready( function() {
<...>
var day_Id = "calendar1_dayId2017-07-17";
someFnc.prototype.getId = function(day_Id) {
<...>
var tempInstFnc = function () {
console.log('in tempInstFnc');
}
var loadTemp = new loadElemProt( day_Id, tempInstFnc );
loadTemp.checkLoadInt = window.setInterval( function() {
loadTemp.checkLoadFnc(); }, 1000 );
var temp = document.getElementById( "calendar1_dayId2017-07-17" )
console.log('temp='); console.log(temp); // null
} //someFnc.prototype.getId = function(day_Id) {
}); //$( document ).ready(function() {
下面是帮助我在上面的代码之前加载的函数
他们永远不会完成,console.log('startedFnc loadElemProt.checkLoadFnc'); //logs forever
var loadElemProt = function ( elemId, userFnc ) {
console.log('STARTED loadElemProt constructor elemId='+elemId )
this.elemId = elemId;
this.userFnc = userFnc;
}; // var loadElemProt = function () {
loadElemProt.prototype.checkLoadFnc = function() {
console.log('startedFnc loadElemProt.checkLoadFnc'); //logs forever
if(document.getElementById(this.elemId)) { this.stopIntervalFnc(); }
}; //loadElemProt.prototype.checkLoadFnc = function() {
loadElemProt.prototype.stopIntervalFnc = function() {
console.log('startedFnc loadElemProt.stopIntervalFnc');
clearInterval(this.checkLoadInt);
this.callUserFnc();
} // loadElemProt.prototype.stopIntervalFnc = function() {
loadElemProt.prototype.callUserFnc = function() {
this.userFnc.call( null )
}