前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >配合JQuery练习

配合JQuery练习

作者头像
仇诺伊
发布2018-09-12 14:43:53
8700
发布2018-09-12 14:43:53
举报
文章被收录于专栏:佳爷的后花媛佳爷的后花媛
代码语言:javascript
复制
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js">
  </script>
  <script type="text/javascript">
    $(document).ready(function(){//文档就绪事件(当 HTML 文档就绪可用时)
      $("p").click(function(){
        $(this).hide();//如果被选的元素已被显示,则隐藏该元素
      });
    });
  </script>
  <title>Document</title>
</head>
<body>
  <p>if you click on me ,i will disappear</p>
</body>
</html> -->
<!-- jQuery 语法实例
$(this).hide()
演示 jQuery hide() 函数,隐藏当前的 HTML 元素。
$("#test").hide()
演示 jQuery hide() 函数,隐藏 id="test" 的元素。
$("p").hide()
演示 jQuery hide() 函数,隐藏所有 <p> 元素。
$(".test").hide()
演示 jQuery hide() 函数,隐藏所有 class="test" 的元素。 -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("button").click(function(){
      $("p").css("background-color","blue");
    });
  });
</script>
  <title>Document</title>
</head>
<body>
  <h2>this is a heading</h2>
  <p>this is a photograph</p>
  <p>this is another photograph</p>
  <button type="button" name="button">click</button>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("button").click(function(){
      $("p").hide();
    });
  });
</script>
  <title>Document</title>
</head>
<body>
<h2>this is a heading</h2>
<p>this is a photograph</p>
<p>this is another photograph</p>
<button type="button" name="button">click</button>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
  $("#hide").click(function(){
    $("p").hide();
  });
  $("#show").click(function(){
    $("p").show();
  });
});

</script>
<body>
  <p id="p1">if click "hide"button,i will disappear.</p>
  <button type="button" id="hide" name="button">hide</button>
  <button type="button" id="show" name="button">show</button>
</body>
</html> -->
<!-- /**
 * show and hide function
 * @type {String}
 */ -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("button").click(function(){
      $("p").hide(1000);
    });
    $("#show").click(function(){
      $("p").show(1000);
    });
  });
</script>
</head>
<body>
  <button type="button" name="button">hide</button>
  <button id="show" type="button" name="button">show</button>
  <p>this is a photograph</p>
  <p>this is another photograph</p>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
  <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        $("p").toggle();
      });
    });
  </script>
</head>
<body>
  <button type="button" name="button">change</button>
  <p>this is a photograph</p>
  <p>this is another photograph</p>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    // $("button").click(function(){
    //   $("#div1").fadeIn();
    //   $("#div2").fadeIn("slow");
    //   $("#div3").fadeIn(3000);
    // });
    $("button").click(function(){
      $("#div1").fadeToggle();
      $("#div2").fadeToggle("slow");
      $("#div3").fadeToggle(3000);
    });
    // $("#out").click(function(){
    //   $("#div1").fadeOut();
    //   $("#div2").fadeOut("slow");
    //   $("#div3").fadeOut(3000);
    // });
  });
</script>
</head>
<body>
  <p>show different fadeIn() methiod</p>
  <button type="button" name="button">click here.</button>
   <button type="button" id="out" name="button">click here and the photo disappear</button>
   <br><br>
  <div id= "div1" style="width:80px;height:80px;display:none;background-color:red;"></div>
  <br>
  <div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div>
<br>
  <div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("#div1").fadeToggle();
    $("#div2").fadeToggle("slow");
    $("#div3").fadeToggle(3000);
  });
});
</script>
</head>
<body>
<p>演示带有不同参数的 fadeToggle() 方法。</p>
<button>点击这里,使三个矩形淡入淡出</button>
<br><br>
<div id="div1" style="width:80px;height:80px;background-color:red;"></div>
<br>
<div id="div2" style="width:80px;height:80px;background-color:green;"></div>
<br>
<div id="div3" style="width:80px;height:80px;background-color:blue;"></div>
</body>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("#div1").fadeTo("slow",0.15);
    $("#div2").fadeTo("slow",0.4);
    $("#div3").fadeTo("slow",0.7);
  });
});
</script>
</head>
<body>
<p>演示带有不同参数的 fadeToggle() 方法。</p>
<button>点击这里,使三个矩形淡入淡出</button>
<br><br>
<div id="div1" style="width:80px;height:80px;background-color:red;"></div>
<br>
<div id="div2" style="width:80px;height:80px;background-color:green;"></div>
<br>
<div id="div3" style="width:80px;height:80px;background-color:blue;"></div>
</body>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <title>Document</title>
</head>
<script type="text/javascript">
  $(document).ready(function(){
    $(".flip").click(function(){
      $(".panel").slideDown("slow");
    });
  });
</script>
<style media="screen" type="text/css">
  div.panel,p.flip{
    margin: 0px;
    padding: 5px;
    text-align: center;
    background: #e5eecc;
    border: solid 1px #c3c3c3;
  }
  div.panel{
    height: 120px;
    display: none;
  }
</style>
<body>
  <div class="panel">
    <p>hello</p>
    <p>your english name is aha!</p>
  </div>
  <p class="flip" >click here</p>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <title>Document</title>
</head>
<script type="text/javascript">
  $(document).ready(function(){
    $(".flip").click(function(){
      $(".panel").slideUp("slow");
    });
  });
</script>
<style media="screen" type="text/css">
  div.panel,p.flip{
    margin: 0px;
    padding: 5px;
    text-align: center;
    background: #e5eecc;
    border: solid 1px #c3c3c3;
  }
  div.panel{
    height: 120px;
    /*display: none;*/
  }
</style>
<body>
  <div class="panel">
    <p>hello</p>
    <p>your english name is aha!</p>
  </div>
  <p class="flip" >click here</p>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <title>Document</title>
</head>
<script type="text/javascript">
  $(document).ready(function(){
    $(".flip").click(function(){
      $(".panel").slideToggle("slow");
    });
  });
</script>
<style media="screen" type="text/css">
  div.panel,p.flip{
    margin: 0px;
    padding: 5px;
    text-align: center;
    background: #e5eecc;
    border: solid 1px #c3c3c3;
  }
  div.panel{
    height: 120px;
    /*display: none;*/
  }
</style>
<body>
  <div class="panel">
    <p>hello</p>
    <p>your english name is aha!</p>
  </div>
  <p class="flip" >click here</p>
</body>
</html> -->

<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <title>Document</title>
  <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        $("div").animate({left:'250px'});
      });
    });
  </script>
  <style type="text/css">
    div.demo{
      background: #98bf21;
      height: 100px;
      width: 100px;
      position: absolute;
    }
  </style>
</head>
<body>
  <button>begin animate</button>
  <p>默认情况下,所有的HTML元素的位置都是静态的,并且无法移动,如需对位置进行操作,记得首先把元素的css position属性设置为relative,fixed或者absolute</p>
  <div class="demo"></div>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <title>Document</title>
  <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        // $("div").animate({
          // // left:'250px',
          // // opacity:'0.5',
          // height:'toggle',
          // // width:'+=150px'
          var div = $("div");
          // div.animate({height:'300px',opacity:'0.4'},"slow");
          // div.animate({width:'300px',opacity:'0.8'},"slow");
          // div.animate({height:'100px',opacity:'0.4'},"slow");
          // div.animate({width:'100px',opacity:'0.8'},"slow");
          div.animate({left:'100px'},"slow");
          div.animate({fontSize:'3em',width:'+=150px'},"slow");
        // });
      });
    });
  </script>
  <style type="text/css">
    div.demo{
      background: #98bf21;
      height: 100px;
      width: 100px;
      position: absolute;
    }
    </style>
</head>
<body>
  <button>begin animate</button>
  <p>默认情况下,所有的HTML元素的位置都是静态的,并且无法移动,如需对位置进行操作,记得首先把元素的css position属性设置为relative,fixed或者absolute</p>
  <div class="demo">hello</div>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <title>Document</title>
  <script>
  $(document).ready(function () {
    $("#flip").click(function(){
      $("#panel").slideDown(5000);
    });
    $("#stop").click(function(){
      $("#panel").stop();
    });
  });
  </script>
  <style media="screen" type="text/css">
#panel,#flip{
  padding: 5px;
  text-align: center;
  background-color: #e5eecc;
  border: solid 1px #c3c3c3;
}
#panel{
  padding: 50px;
  display: none;
}
  </style>
</head>

<body>
  <button id="stop">stop slide</button>
  <div id="flip">click here ,slideDown the panel
  </div>
  <div id="panel">hello ,you are my baby!
  </div>
</body>
</html>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.11.19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档