這個事件很常會使用JS來做,但最近覺得可以用CSS解決的事就盡量少用JS
解法其實也很簡單,只要把selector放在A物件:hover後面就能實現
參考
If the cube is directly inside the container:
#container:hover > #cube { background-color: yellow; }
If cube is next to (after containers closing tag) the container:
#container:hover + #cube { background-color: yellow; }
If the cube is somewhere inside the container:
#container:hover #cube { background-color: yellow; }