逐条读取 javaScript 中的数组数据
2017-02-13 本文已影响15人
xiaojianxu
逐条读取 javaScript 中的数组数据
<html>
<head>
<title>DEMO JavaScript</title>
<script type="text/javascript">
var messsage = {
0: {name : 'james', sex : 'man'},
1: {name : 'gogo', sex : 'unknown'},
2: {name : 'dindin', sex : 'unknown'}
};
</script>
</head>
<body>
<div>
<input type="button" id="next_one" value="Next" />
</div>
<script type="text/javascript">
var btn = document.getElementById('next_one');
var index = 0;
btn.addEventListener("click", function() {
console.log(messsage[index]);
index++;
console.log(index);
});
console.log("keys:" + messsage.keys);
//console.log(document.getElementsByClassName("next_btn"));
/*
btn.onclick = function() {
console.log(12121);
}
*/
console.log(btn);
/*.addEventListener('click', function(event) {
console.log(event);
});
*/
</script>
</body>
</html>