html
<button>点击文字变红</button>
<p>trigger出发点击事件</p>
js
$('button').click(function(event) {
$(this).next().css('color','red');
});
$('button').trigger('click'); //不用点击颜色就变红了
或者通过a来点击b
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<style type="text/css">
div{ 200px;height: 200px;margin:20px;background-color:pink;}
</style>
<body>
<div class='box1' onclick='box1(this)'>盒子1</div>
<div onclick='box2(this)'>盒子2</div>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
function box1(self){
console.log(self)
}
function box2(self){
$('.box1').trigger("click")
}
</script>
</html>