欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

jquery使用hide方法隐藏指定id的元素

程序员文章站 2022-06-20 18:00:32
本文实例讲述了jquery使用hide方法隐藏指定id的元素。分享给大家供大家参考。具体如下: 下面的代码通过jquery的hide方法隐藏了id=test的元素 &l...

本文实例讲述了jquery使用hide方法隐藏指定id的元素。分享给大家供大家参考。具体如下:

下面的代码通过jquery的hide方法隐藏了id=test的元素

<!doctype html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $("#test").hide();
 });
});
</script>
</head>
<body>
<h2>this is a heading</h2>
<p>this is a paragraph.</p>
<p id="test">this is another paragraph.cnblogs.com</p>
<button>click me</button>
</body>
</html>