开发者社区 问答 正文

jQuery怎么遍历当前页面的textbox,添加onclik事件?

我是这么写的:

$(function(){
            var j=1;//index each bin
            for (var i=0;i<pan_cnt; i++) {
                var v_tb_id = "#tbl_" + i;
                $("#form1 " + v_tb_id +" input[type='text']").each(function(){                
                        
                       $(this).onclick(function(){alert('me');});                  
                       j++;                                 
                     
                });
            }       
        });

报错:
Line: 1155
Error: Object doesn't support this property or method

展开
收起
a123456678 2016-07-12 14:17:18 2158 分享 版权
1 条回答
写回答
取消 提交回答
  • $(this).click() 不是onclick

    2019-07-17 19:54:53
    赞同 展开评论