jQuery hover and class selector

后端 未结 10 1704
半阙折子戏
半阙折子戏 2020-12-10 00:56

I wan\'t to change the background color of a div dynamicly using the following HTML, CSS and javascript. HTML:


      
      
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 01:30

    I prefer foxy's answer because we should never use javascript when existing css properties are made for the job.

    Don't forget to add display: block ; in .menuItem, so height and width are taken into account.

    edit : for better script/look&feel decoupling, if you ever need to change style through jQuery I'd define an additional css class and use $(...).addClass("myclass") and $(...).removeClass("myclass")

提交回复
热议问题