How to define the css :hover state in a jQuery selector?

后端 未结 6 510
梦谈多话
梦谈多话 2020-11-30 04:10

I need to define a div\'s background color on :hover with jQuery, but the following doesn\'t seem to work:

$(\".myclass:hover div\").css(\"background-color\         


        
6条回答
  •  野性不改
    2020-11-30 05:12

    It's too late, however the best example, how to add pseudo element in jQuery style

     $(document).ready(function(){
     $("a.dummy").css({"background":"#003d79","color":"#fff","padding": "5px 10px","border-radius": "3px","text-decoration":"none"});
     $("a.dummy").hover(function() {
                $(this).css("background-color","#0670c9")
              }).mouseout(function(){
                  $(this).css({"background-color":"#003d79",});
              });
     
     });
    
    Just Link

提交回复
热议问题