mouseover() 方法


<html>

<head>

<script type="text/javascript" src="/jquery/jquery.js"></script>

<script type="text/javascript">

$(document).ready(function(){

  $("p").mouseover(function(){

    $("p").css("background-color","yellow");

  });

  $("p").mouseout(function(){

    $("p").css("background-color","#E9E9E4");

  });

});

</script>

</head>

<body>

<p style="background-color:#E9E9E4">请把鼠标指针移动到这个段落上。</p>

</body>

</html>


jQuery 效果 - 隐藏和显示

<!DOCTYPE html>

<html>

<head>

<script src="/jquery/jquery-1.11.1.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){

  $("#hide").click(function(){

  $("p").hide();

  });

  $("#show").click(function(){

  $("p").show();

  });

});

</script>

</head>

<body>

<p id="p1">如果点击“隐藏”按钮,我就会消失。</p>

<button id="hide" type="button">隐藏</button>

<button id="show" type="button">显示</button>

</body>

</html>


两个结合之后的代码

$(function() {

$("#tzgg1").addClass('title_h2');//设置其中一个初始时的效果


});

$(document).ready(function() {

$("#tzgg1").mouseover(function() {

$("#tzgg1").addClass('title_h2');

$("#gzdt1").removeClass('title_h2');

$("#tzgg2").show();

$("#gzdt2").hide();

$("#tzgg3").show();

$("#gzdt3").hide();

});wKiom1m_wqnQWEhJAAAzJ2glJTA640.png-wh_50

$("#gzdt1").mouseover(function() {

$("#gzdt1").addClass('title_h2');

$("#tzgg1").removeClass('title_h2');

$("#gzdt2").show();

$("#tzgg2").hide();

$("#gzdt3").show();

$("#tzgg3").hide();

});

});

wKioL1m_wo6As1c7AABAxnFhfjA499.png-wh_50