jQuery Mobile 百分网手机站

jQuery中hide()方法运用示例

时间:2018-04-23 20:33:36 jQuery Mobile 我要投稿

jQuery中hide()方法运用示例

  jQuery中hide()方法运用示例

  此方法可以将匹配元素隐藏。

  hide()方法的用法:

  此方法如果没有对隐藏效果加以时间限定,那么匹配元素会被瞬间隐藏。例如:

  复制代码 代码如下:$("div").hide()

  以上代码可以将所有div元素瞬间隐藏。

  如果方法对隐藏效果加以时间限定,那么匹配元素将会在限定的事件内以比较优雅的形式隐藏。例如:

  复制代码 代码如下:$("div").hide(2000)

  以上代码可以将所有div元素在2000毫秒(2秒)内隐藏。

  此方法也可以在隐藏完成后触发一个回调函数。例如:

  复制代码 代码如下:$("div").hide(2000,function(){alert("我隐藏好了")});

  实例代码:

  复制代码 代码如下:

  div{

  color:blue;

  background-color:green;

  width:100px;

  height:100px;

  margin-top:10px;

  }

  $(document).ready(function(){

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

  $(".first").hide();

  })

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

  $(".second").hide(2000,function(){alert("我隐藏好了")});

  })

  })

  瞬间隐藏

  优雅的'隐藏

  以上代码能够在隐藏完成以后触发回调函数,于是弹出一个提示框。

  希望本文所述对大家的jQuery程序设计有所帮助。

【jQuery中hide()方法运用示例】相关文章:

1.jQuery中offset()方法运用示例

2.jQuery中ajax的get()方法运用示例

3.jQuery中trigger方法用法

4.jQuery中replaceAll()方法用法

5.jQuery中prev()方法用法

6.jQuery中outerWidth的方法介绍

7.jquery中toggle方法使用例子

8.jQuery中nextAll()方法用法欣赏