change background of parent div on hover

前端 未结 6 1153
情书的邮戳
情书的邮戳 2020-12-31 13:05

I have this code:

6条回答
  •  囚心锁ツ
    2020-12-31 13:25

    You can't. CSS does not have any way to select the "parent element":

    http://snook.ca/archives/html_and_css/css-parent-selectors

    Would prefer not to use jQuery, but don't mind too much.

    Use: http://jsfiddle.net/KHc6X/

    $('.thumb_image_holder_orange > img').hover(function(){
        $(this).parent().toggleClass('hover');
    })
    

提交回复
热议问题