Applications of DOM

Hiding elements

In one of our previous chapter, we discussed how we set, change, or remove the attribute values of an element. Lets see how it can be used here :-

Click me
I will vanish
<a href='javascript:hideshow(document.getElementById('mydiv'))'>Click me</a>

<script type='text/javascript'>
function hideshow(obj){
if (!document.getElementById)
return
if (obj.style.display=='block')
obj.style.display='none';
else
obj.style.display='block';
}
</script>

<div id='mydiv' style='font:24px bold; display: block'>I will vanish</div>

We have used a simple function hideshow which is triggered once the link is clicked. The function toggles the display attribute of element :-

Lets see some basic animations that can be done using DOM :-

Member Login

Member Login




Not a Member? Sign Up!




Login to comment

Be the first to comment on this topic







  


<<< Wanna review

Continue >>>