I am trying to make a page with buttons that will change the color scheme of the page. I have gotten much of it working, as you can view here https://jsfiddle.net/v0jx4wdz/. However I can not seem to get anything to work for hover on onmouseover. I would like to still be able to style the buttons and focus area. I have been looking for a solution in just Javascript for this all day, but have had no luck at all.
EDIT: To clarify, I am not looking to have an onmouseover function used as a way to make the style change to the page. I am looking to have the style change take place, and the buttons labeled "Button" have an onmouseover change. At the start it's two shades of blue. But I would like to be able to have it be 2 other colors.
I have tried
var formArea = document.getElementByClassName("formArea").onclick =
function() {
this.style.borderColor = "black";
}
But when added to the whole code, it all falls apart.
Here's what I have been working with.
<style>
body {
background-color: #ec7c23;
}
.btn-group button {
background-color: #577CC1;
border: 1px #577CC1;
color: white;
padding: 10px 24px;
cursor: pointer;
float: left;
font-weight: bold;
}
.btn-group:after {
content: "";
clear: both;
display: table;
}
.btn-group button:not(:last-child) {
border-right: none;
}
.btn-group button:hover {
background-color: #2C3E60;
}
textarea[type="textarea"] {
width: ;
padding: 5px 10px;
margin: 5px 0;
box-sizing: border-box;
font-family: arial;
font-weight: bold;
border: 10px;
background-color: #F4F6FA;
color: darkblue;
border: 4px solid #577CC1;
border-radius: 4px;
}
textarea[type="textarea"]:focus {
border: 4px solid #e66026;
}
h1 {
line-height: 1.25;
margin: 2em 0 0;
}
p {
margin: .5em 0;
}
#switcher {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#switcher li {
float: left;
width: 30px;
height: 30px;
margin: 0 15px 15px 0;
border-radius: 30px;
border: 3px solid black;
}
#blackButton {
background: grey;
}
#orangeButton {
background: #ec7c23;
}
</style>
HTML
<textarea type="textarea" class="formArea" name="output"
onclick="this.focus();this.select()"
id="output" cols="70" rows="25" placeholder="Some text"></textarea>
<br>
<div class="btn-group">
<button value="Combine" class="buttonGroup" onclick="convert()"
id="combine1">
Button
</button><br><br>
</div>
<br>
<textarea type="textarea" class="formArea" name="output"
onclick="this.focus();this.select()"
id="output" cols="70" rows="5" placeholder="Some text"></textarea>
<br>
<div class="btn-group">
<button value="Combine" class="buttonGroup" onclick="convert()"
id="combine1">
Button
</button><br><br>
</div>
<br>
<ul id="switcher">
<li id="blackButton"></li>
<li id="orangeButton"></li>
</ul>
javascript
<script>
document.getElementById('blackButton').onclick = switchBlack;
document.getElementById('orangeButton').onclick = switchOrange;
function switchBlack() {
var textareafocus = document.querySelectorAll('textareafocus')
for(var i = 0; i < body.length; i++) {
body[i].style.backgroundColor = "grey";
}
var body = document.getElementsByTagName('body')
for(var i = 0; i < body.length; i++) {
body[i].style.color = 'white';
body[i].style.backgroundColor = "grey";
body[i].style.fontFamily = 'terminal';
}
var formArea = document.getElementsByClassName('formArea')
for(var i = 0; i < formArea.length; i++) {
formArea[i].style.backgroundColor = 'black';
formArea[i].style.borderColor = 'white';
formArea[i].style.color = 'white';
formArea[i].style.fontFamily = 'terminal';
var formArea = document.getElementByClassName("formArea").onclick =
function() {
this.style.borderColor = "black";
}
}
var buttonGroup = document.getElementsByClassName('buttonGroup')
for(var i = 0; i < buttonGroup.length; i++) {
buttonGroup[i].style.backgroundColor = 'white';
buttonGroup[i].style.color = 'black';
}
var buttonGroup = document.getElementByClassName("buttonGroup").onmouseover
= function() {
this.style.backgroundColor = "orange";
}
var buttonGroup = document.getElementByClassName("buttonGroup").onmouseout =
function() {
this.style.backgroundColor = "white";
}
}
function switchOrange() {
var body = document.getElementsByTagName('body')
for(var i = 0; i < body.length; i++) {
body[i].style.color = '#2C3E60';
body[i].style.backgroundColor = "#ec7c23";
body[i].style.fontFamily = 'arial';
}
var formArea = document.getElementsByClassName('formArea')
for(var i = 0; i < formArea.length; i++) {
formArea[i].style.backgroundColor = 'lightblue';
formArea[i].style.borderColor = '#577CC1';
formArea[i].style.color = 'darkblue';
formArea[i].style.fontFamily = 'arial';
var formArea = document.getElementByClassName("formArea").onclick =
function() {
this.style.borderColor = "orange";
}
}
var buttonGroup = document.getElementsByClassName('buttonGroup')
for(var i = 0; i < buttonGroup.length; i++) {
buttonGroup[i].style.backgroundColor = '#577CC1';
buttonGroup[i].style.color = 'white';
}
var buttonGroup = document.getElementByClassName("buttonGroup").onmouseover
= function() {
this.style.backgroundColor = "blue";
}
var buttonGroup = document.getElementByClassName("buttonGroup").onmouseout =
function() {
this.style.backgroundColor = "white";
}
}
</script>
I even tried playing around with querySelectorAll, but that didn't seem to work at all.
If someone knows anyway to pull this off, that would be really cool. Please, just javascript, no JQuery.