Home > Web Front-end > JS Tutorial > jquery uses each method to traverse json format data instances_jquery

jquery uses each method to traverse json format data instances_jquery

WBOY
Release: 2016-05-16 15:58:27
Original
1257 people have browsed it

The example in this article describes how jquery uses the each method to traverse json format data. Share it with everyone for your reference. The specific implementation method is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
  //$.each(array,fn)对数组arry每个元素调用fn函数进行处理,没有返回值
  var arr = { "tom": "汤姆", "jerry": "杰瑞", "lily": "莉莉" };
  //json格式的对象(dict)
  $.each(arr, function (key, value) { alert(key + "=" + value); });
  //如果是普通风格的数组,则key的值是序号。
</script>
</head>
<body>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template