Home  >  Article  >  Web Front-end  >  Usage example of jQuery compound event combined with toggle()

Usage example of jQuery compound event combined with toggle()

小云云
小云云Original
2018-01-10 09:34:031507browse

This article mainly introduces the use of jQuery compound events combined with the toggle() method. The example analyzes the function, definition and operation skills of the toggle() method combined with compound events. Friends who need it can refer to it. I hope it can help. Everyone.

The example in this article describes the use of jQuery compound events combined with the toggle() method. Share it with everyone for your reference, the details are as follows:

Definition and usage

toggle() method is used to bind two or more event handler functions to respond to the turn of the selected element click event.

Syntax:

$(selector).toggle(function1(),function2(),functionN(),...)
When the specified element is clicked, between the two Or alternate between multiple functions.

Bound with the methods hide() and show() to achieve the folding effect;

Specific examples:

<script type="text/javascript" src="js/jquery.js "></script>
<script type="text/javascript">
 $(function(){
    $("#dt1").toggle(
      function(){$("#p1").show();},
      function(){$("#p1").hide();}
    );
   })
</script>
<dl>
  <dt id="dt1">新闻管理</dt>
  <p id="p1">
  <dd>发布新闻</dd>
  <dd>新闻列表</dd>
  <dd>回收站</dd>
  </p>
</dl>

Related recommendations:

Related jQuery compound event usage examples

jQuery.fadeToggle() function usage details

jQuery.toggle() function usage examples

The above is the detailed content of Usage example of jQuery compound event combined with toggle(). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn