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

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

巴扎黑
巴扎黑Original
2017-06-21 16:35:411739browse

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>

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!

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