CSS/JS Solution: On hover of child element, change parent div

后端 未结 5 827
半阙折子戏
半阙折子戏 2021-01-16 04:56

I know CSS is \"cascading\", but in this case I want the effect to ascend. I\'m open for either a JS or CSS solution, but honestly I\'d prefer the solution with the least a

5条回答
  •  醉酒成梦
    2021-01-16 05:34

    The solution would probably be JS:

    $(".letter").hover(function() {
        $(this).closest("#word").toggleClass("hovered")
    });
    

    Here is a fiddle: http://jsfiddle.net/zT9AS/2

提交回复
热议问题