Forum Moderators: open
I'm trying to create a function that will change the opacity of a div.
I've got a sample below and my most recient attempt, but I'm not having much luck.
What I'm trying to do is create fade in and fade out effects by changing the opacity.
This is my most recient attempt.
<html>
<head>
<DIV id="Image" style="position:absolute; left=50; top=50; filter:alpha(opacity=10);">
<IMG src="Files/Image 1.jpg">
</DIV>
</head>
<body>
<SCRIPT language=Javascript>
function changeOpacity()
{window.document.all.Image.style.opacity=50;}
changeOpacity()
</SCRIPT>
</body>
</html>
But the above function doesn't work. Help.
</head>
<body>
<SCRIPT language=Javascript>
function changeOpacity()
{window.document.all.Image.style.opacity=50;}
to this:
<DIV name="Image" style="position:absolute; left=50; top=50; filter:alpha(opacity=10);">
<IMG src="Files/Image 1.jpg">
</DIV>
</head>
<body>
<SCRIPT language=Javascript>
function changeOpacity()
{if (Image.style.MozOpacity) {Image.style.MozOpacity=0.5;}
if (Image.style.filter) {Image.style.filter='alpha(opacity=50)';}}
i think all should be well here)
good luck to you!