Shaolins-Finest
02-01-2008, 04:38 PM
Hi guys,
I have some js and a div tag with a class property. Now when the user clicks a link the javascript should change the div tag class property, in this case, from setnone to setdisplay (css properties). But when I click the link, the content between the div tag displays but only for a fraction of a second and then disappears. See code below:
HTML:
<a href="" onmouseup="changeClass();">Edit Events</a>
<div id="eventsetting" class="setnone">
//stuff in here
</div>
Javascript:
function changeClass()
{
setClassName("eventsetting","setdisplay");
}
function setClassName(targetName, nameOfClass)
{
var target = document.getElementById(targetName)
if(document.implementation && document.implementation.createDocument)
{
target.setAttribute("class", nameOfClass);
} else {
target.className = nameOfClass;
}
}
css:
.setnone {
display : none;
}
.setdisplay {
display : inline;
}
I have some js and a div tag with a class property. Now when the user clicks a link the javascript should change the div tag class property, in this case, from setnone to setdisplay (css properties). But when I click the link, the content between the div tag displays but only for a fraction of a second and then disappears. See code below:
HTML:
<a href="" onmouseup="changeClass();">Edit Events</a>
<div id="eventsetting" class="setnone">
//stuff in here
</div>
Javascript:
function changeClass()
{
setClassName("eventsetting","setdisplay");
}
function setClassName(targetName, nameOfClass)
{
var target = document.getElementById(targetName)
if(document.implementation && document.implementation.createDocument)
{
target.setAttribute("class", nameOfClass);
} else {
target.className = nameOfClass;
}
}
css:
.setnone {
display : none;
}
.setdisplay {
display : inline;
}