使用函数通过getElementById()获取元素的ID

时间:2011-03-09 02:04:12

标签: javascript function parameters onclick getelementbyid

GET_COOKIE('CURRENT_IM')将返回保存在CURRENT_IM cookie中的数字。我怎样才能让它发挥作用?

这是一个onClick属性

document.getElementById('IM_INNER_'+GET_COOKIE('CURRENT_IM')).style.display='none';

1 个答案:

答案 0 :(得分:0)

什么不起作用?

我对调试的直接想法是设置一个变量。此外,在整数返回值上调用toString()可能会有所帮助。

  var id = 'IM_INNER_'+GET_COOKIE('CURRENT_IM').toString();
  alert(id);  //this will tell you what the id is.  you can view the source to see if it's correct
  document.getElementById(id).style.display='none';