0
我需要注册一个点击事件,并需要调用相同的事件,当我点击(“$ P2”)元素注册一个点击事件并调用同一事件
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function(){
$("#p1").on('click', function(event) {
console.log('clicked = ', $(this).text());
$("#p2").on('click', function(event) {
$("p").trigger('click');
})
})
});
</script>
<style>
</style>
</head>
<body>
This is a scratch html.
<br>
<p id="p1">This is paragraph - p1</p>
<p id="p2">This is paragraph - p2</p>
</body>
</table>
</html>
像http://jsfiddle.net/arunpjohny/Wchfk/1/ –