jQuery click() trigger click event

Introduction

Trigger click event for p element

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*from w w  w  .  j  av a2  s  . co  m*/
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").click();
  });
});
</script>
</head>
<body>

<button>test</button>

<p onclick="document.write('Click event triggered')">
This is a paragraph.</p>

</body>
</html>



PreviousNext

Related