【问题标题】:<div> has to "delete" it's content on moseover<div> 必须在鼠标悬停时“删除”其内容
【发布时间】:2013-01-31 09:46:57
【问题描述】:

所以我遇到了一些问题,鼠标悬停工作,但我需要更多的东西,当背景改变时它必须删除它的内容。

#Test01{
background: url(../img/Test01.png);
float: left;
display: block;
height: 297px;
width: 319px;
} 
#Test01:hover {
background: url(../img/Test01hover.png);
}

<div id="Test01"><div id="test01content">lot's of bla bla bla bla bla</div></div>

所以当鼠标悬停时,这个 div 的内容应该消失了。

谢谢

【问题讨论】:

  • 你可以使用 jQuery 轻松做到这一点!
  • 那我应该使用什么代码?

标签: html hover mouseover


【解决方案1】:

不要用CSS,试试用Javascript来实现,

$("#Test01").hover(function(){
   $(this).css("background-image", "url(../img/Test01hover.png)")
   $(this).empty();
});

【讨论】:

  • 再试一次,我错过了# in $("#Test01")
【解决方案2】:

尝试使用 jQuery

$("#Test01").mouseover(function(){
   $(this).empty();
});

【讨论】:

    猜你喜欢
    • 2014-06-17
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    相关资源
    最近更新 更多