作者averywu (看文不要只會用橫的看)
看板Ajax
標題[問題] Bind 事件時抓取自已?
時間Mon Dec 24 20:57:36 2012
$('.somespan').bind('click',function(){
var str = $(this).attr('alt')
alert(str)
})
當然上面是不能用的,有法子達到上述效果嗎?
當綁定事件在一群相同元素上時,抓到觸發事件的那個元素要怎麼抓呢?
用 $(this) 行不通,用 this 也行不通。
--
小惡魔的家
http://blog.pixnet.net/shiuju/
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.251.237.155
1F:→ akiratw:$(this) 為何不能用…? 12/24 21:04
2F:→ kerash:我測試可以 12/24 21:05