можно так:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>ГГ</title>
<style>
*{
margin:0;
padding:0;
outline: 0;
}
.container {
margin: 50px;
width: 100px;
height: 100px;
border: 1px solid red;
}
.block {
margin: 10px;
width: 50px;
height: 50px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="container">
<div class="block" contenteditable></div>
</div>
<script>
var container = document.getElementsByClassName('container')[0];
var block = document.getElementsByClassName('block')[0];
container.onmousemove = function(){
block.style.backgroundColor = 'yellow';
container.onkeyup = function(){
block.style.backgroundColor = 'blue';
}
}
</script>
</body>
</html>
а можно и так:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>ГГ</title>
<style>
*{
margin:0;
padding:0;
outline: 0;
}
.container {
margin: 50px;
width: 100px;
height: 100px;
border: 1px solid red;
}
.block {
margin: 10px;
width: 50px;
height: 50px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="container">
<div class="block" contenteditable></div>
</div>
<script>
var container = document.getElementsByClassName('container')[0];
var block = document.getElementsByClassName('block')[0];
container.onmousemove = function(){
block.style.backgroundColor = 'yellow';
}
container.onkeyup = function(){
block.style.backgroundColor = 'blue';
}
</script>
</body>
</html>