jQuery mousedown() trigger slide event

Description

jQuery mousedown() trigger slide event

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>// w w  w.  ja va 2  s. c  o m
<script>
$(document).ready(function(){
  $("button").mousedown(function(){
    $("p").slideToggle();
  });
  $("div").mouseover(function(){
    $("button").mousedown();
  });
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>

<button>Toggle</button><br><br>

<div>Mouse over this text to trigger the 
mousedown event for the button above.</div>

</body>
</html>



PreviousNext

Related