Log in

View Full Version : Multiple IDs in getElementByIDs



dassurai
07-22-2008, 12:00 PM
Hey i am new to javascript and trying to modify this
<script type="text/javascript">
document.onclick=check;
function check(e){
var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById('content');
checkParent(target)?obj.style.display='none':null;
}
function checkParent(t){
while(t.parentNode){
if(t==document.getElementById('content')){
return false
}
t=t.parentNode
}
return true
}
</script>

basically i have two divs with different ids i need to have this functionality on both the divs. when i am putting the script for a single div its works fine. my question is how can i have the functionality with two different divs having two different ids.
please help
thanks in advance

Nile
07-22-2008, 12:47 PM
Please only post one thread, posting more then one will not get anymore attention.