Trigger click event
Description
The following code shows how to trigger click event.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!--from w ww.j a va2 s .co m-->
$("h1").click(function() {
alert("h1");
});
$("button:last").click(function() {
$("h1").trigger('click');
});
});
</script>
</head>
<body>
<div>
<h1>java 2s.com</h1>
</div>
<button value="java2s.com">java2s.com</button>
</body>
</html>