GET_COOKIE('CURRENT_IM')将返回保存在CURRENT_IM cookie中的数字。我怎样才能使这个工作?使用函数getElementById()获取元素的ID
这是在onclick属性
document.getElementById('IM_INNER_'+GET_COOKIE('CURRENT_IM')).style.display='none';
GET_COOKIE('CURRENT_IM')将返回保存在CURRENT_IM cookie中的数字。我怎样才能使这个工作?使用函数getElementById()获取元素的ID
这是在onclick属性
document.getElementById('IM_INNER_'+GET_COOKIE('CURRENT_IM')).style.display='none';
什么是不工作?
我的调试立即想到将设置一个变量。此外,在整数返回值上调用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';
我得到“IM_INNER_” – 2011-03-09 02:14:08
GET_COOKIE没有返回任何内容? – JCOC611 2011-03-09 02:15:04
这意味着GET_COOKIE函数已损坏并返回空值。 – smartcaveman 2011-03-09 02:15:12
onclick属性是单引号还是双引号? – 2011-03-09 02:07:10
双引号,它说document.getElementById(“IM_INNER_”+ GET_COOKIE(“CURRENT_IM”))为空 – 2011-03-09 02:08:35
你可以上传一些源代码在jsfiddle(http://jsfiddle.net/) – mellamokb 2011-03-09 02:09:38