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/ –