Buenas lo que quiero es cambiar el color del body o algun padre pasando el mouse sobre el hijo, eh estado buscando información y no encuentro no se si es posible..
Dejo lo que eh probado:
td div:hover body{
color:#b42803;
}
Cabe resaltar que esto me funciona en los hijos..
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#parent
{
color: red;
}
#child
{
color: indigo;
}
</style>
</head>
<body>
<a id="parent" href="#">
Parent text
<span id="child">Child text</span>
</a>
<script>
parent = document.getElementById("parent")
child = document.getElementById("child")
function change_parent_black()
{
parent.style.color = "black"
}
function change_parent_red()
{
parent.style.color = "red"
}
child.addEventListener("mouseover", change_parent_black);
child.addEventListener("mouseout", change_parent_red)
</script>
</body>
</html>
B#
Gracias gracias, una pregunta solo se puede lograr con JS?, no hay posibilidad de solo usar CSS
Se están empezando a implementar soluciones en CSS pero aún no son compatibles con los navegadores: https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector
Cita de: EdePC en 13 Septiembre 2020, 22:31 PM
Se están empezando a implementar soluciones en CSS pero aún no son compatibles con los navegadores: https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector
Gracias!