Home > Web Front-end > JS Tutorial > body text

Usage example of jQuery compound event combined with toggle() method

巴扎黑
Release: 2017-06-21 16:35:41
Original
1748 people have browsed it

This article mainly introduces jQueryCompositeEventCombined with the usage of the toggle() method, the example analyzes the function, definition and use of the toggle() method in conjunction with composite events For operational skills, friends in need can refer to

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 Define two or more event handler function to respond to the click event of the selected element in turn.

Syntax:

$(selector).toggle(function1(),function2(),functionN(),.. .)<br>Alternates between two or more functions when the specified element is clicked.

Bound with methods hide() and show() to achieve 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

The above is the detailed content of Usage example of jQuery compound event combined with toggle() method. 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