首頁  >  文章  >  web前端  >  jQuery中show與hide方法用法範例

jQuery中show與hide方法用法範例

巴扎黑
巴扎黑原創
2017-06-29 10:45:112680瀏覽

這篇文章主要介紹了jQuery中show與hide方法用法,結合實例形式分析了jQuery使用show與hide方法控制頁面元素顯示與隱藏的簡單實現技巧,需要的朋友可以參考下

本文實例分析了jQuery中show與hide方法用法。分享給大家參考,具體如下:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <style type="text/css">
    *{font-size:12px;}
    p{width:600px;margin:auto;}
    #control{background-color:gold;padding:10px;}
  </style>
  <script src="../js/jquery-1.5.1.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {
      $("#btnDisplay").click(function () {
        $("#message").show(3000);
      });
      $("#btnHide").click(function () {
        $("#message").hide(3000);
      });
    });
  </script>
</head>
<body>
  <p id="control">
    <input id="btnDisplay" type="button" value="显示p" />
    <input id="btnHide" type="button" value="隐藏p" />
  </p>
  <p id="message">
    mouseover、mouseenter的区别:p里套p。见备注。和事件冒泡有关系。<br /> 
    不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件 <br />
    只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件(穿过子元素不会触发)
  </p>
</body>
</html>

以上是jQuery中show與hide方法用法範例的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn