jQuery - 將function綁定再img上

$(document).ready(function() {
    // 將element中的img的id有開頭為"img_"的 全部綁上這個function
    $("img[id^='img_']").bind("click",function(){
    // 在其中可直接取得該element的src
    ch_pic($(this).attr('src'));
  });
});
Reference : http://design2u.me/blog/943/jquery-notes-g-selector-the-selector

留言

這個網誌中的熱門文章

[翻譯] 介紹現代網路負載平衡與代理伺服器

Grafana K6

Linux 事件驅動筆記