div css 滑鼠移至上方在div層上時,div背景色改變

來源:互聯網
上載者:User

如果要實現,當滑鼠移到div層上時,改變其背景色,我試了好多方法,只有這個方法可行,百度上其他的似乎有問題,暫且這樣說吧。

<style>
.normal{background-color:white}//正常時候div層的樣式,也可以添加其他樣式表屬性。

.change{background-color:red}//改變後的div層的樣式,也可同時添加其他樣式表屬性。
</style>
<body>
<div onmouseover="this.className='change'" onmouseout="this.className='normal'"><a href="#">放上來就變色</a></div>
</body>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.