值传参
<ul id="menu"> <li id='item1' class="">房产</li> <li id='item2' class="">家居</li> <li id='item3' class="">二手房</li> </ul> <div class='panel'> <ul class="list"> <li>1</li> <li>1</li> <li>1</li> <li>1</li> </ul> </div> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script> <script> var omenu =$('#menu'), aLi = $('#menu li'), opaner = $('.panel'), apaner = $('.panel li'); console.log(apaner) $.each(aLi,function(index,val){ console.log(aLi[index]) var ev= aLi[0]; (function (ev){ this.a(ev); }(ev)) }) console.log(ev) function a(ev){ this.ev = ev; } console.log(ev) // $.each(apaner,function(index,val){ // console.log(apaner[index]) // }) 当你点击的时候,会触发ev事件源对象 ev.addEventListener('click',function (event){ var target = event.target; console.log(event.target) })
或者
function c(ev){
var cc = this.ev;
console.log(cc)
}