我有一个JavaScript函数,使用document.getElementById
获取对象。
function updateQuestPartElemement(obj){
var objid = obj.id;
var quesids = objid.split("$|$");
var qplabelid = quesids[0] + '$|$' + quesids[1] + '$|$' + 'questionPartLabel';
alert(qplabelid); //removing this alert, the below object is coming as null
var qpartlabel = document.getElementById(qplabelid);
alert(qpartlabel);
}
问题是我不需要qplabelid
的提醒。但是,如果我删除此警报,document.getElementById(qplabelid)
不会返回任何对象。我很迷惑。请告诉我一些事情来获取对象。