如果删除警报,document.getElementById将返回null

时间:2014-07-23 11:04:27

标签: javascript

我有一个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)不会返回任何对象。我很迷惑。请告诉我一些事情来获取对象。

0 个答案:

没有答案