Using a function to get the ID of an element with getElementById()
GET_COOKIE('CURRENT_IM') will re开发者_开发技巧turn a number saved in the CURRENT_IM cookie. How can I get this to work?
This is in a onClick Attribute
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.
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';
精彩评论