Background Color - Joomla! Forum - community, help and support
hello everyone,
i've added javascript site changes background of <div id="main"> clicking button.
here code:
i want extend clicking button, background color , text color change , add button reset previous style.
any ideas on how that?
thanks!
i've added javascript site changes background of <div id="main"> clicking button.
here code:
code: select all
<head>
<script type="text/javascript">
function changecolor()
{
var maincontent = "";
maincontent = document.getelementbyid("main");
maincontent.style.backgroundcolor = "#d1d1d1";
}
</script>
</head>
<body>
<div id="main">
<input type="button" id="cmdchangecolor"
name="cmdchangecolor" value="change background color"
onclick="changecolor();" />
</body>
i want extend clicking button, background color , text color change , add button reset previous style.
any ideas on how that?
thanks!
i found solution:
code: select all
<head>
<script type="text/javascript">
function changecolor()
{
document.getelementbyid("main").style.backgroundcolor = "#000000";
document.getelementbyid("main").style.color = "#ffffff";
}
function defaultcolor()
{
document.getelementbyid("main").style.backgroundcolor = "";
document.getelementbyid("main").style.color = "";
}
</script>
</head>
<body>
<div id="main">
<input type="button" id="changecolor"
name="changecolor" value="change color"
onclick="changecolor();" />
<input type="button" id="changecolor"
name="changecolor" value="change back"
onclick="defaultcolor();" />
</body>
Comments
Post a Comment