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

Usage example of jQuery compound event combined with toggle()

小云云
Release: 2018-01-10 09:34:03
Original
1536 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template