jquery 遍历json对象,为按钮添加键盘事件

来源:互联网 发布:ubuntu下chmod 编辑:程序博客网 时间:2024/06/06 07:28

js截取字符串:data.substr(0,2)//从0索引开始截取2位,data.subString(0,2);//截取0开始到1字符串

var jsonData = eval(jsonText);//将字符串解析为Json对象:

$.each(jsonData.countById,function(index,content){

 var send_idfind = content.send_id;//context为countById对象的内容

var countlength = jsonData.countById.length;//countById对象的长度(个数)

$('#chatValue'+content.send_id).keydown(function (event){

if(event.which == 13){

alert('回车');

}

});

 

})

 

原创粉丝点击