[英]Using a function to get the ID of an element with getElementById()
GET_COOKIE('CURRENT_IM') will return a number saved in the CURRENT_IM cookie. GET_COOKIE('CURRENT_IM')将返回保存在CURRENT_IM cookie中的数字。 How can I get this to work?
我该如何工作?
This is in a onClick Attribute 这是在onClick属性中
document.getElementById('IM_INNER_'+GET_COOKIE('CURRENT_IM')).style.display='none';
What is not working? 什么不起作用?
My immediate thought for debugging would be to set a variable. 我立即想到的调试方法是设置一个变量。 Also, calling the
toString()
on the integer return value may help. 此外,调用
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';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.