js从数组中到处新闻列表
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
a{
color: #333;
text-decoration: none;
}
a:hover{
color: red;
text-decoration: underline;
}
</style>
<script type="text/javascript">
window.onload = function(){
var aUl = document.getElementById('list');
var arr = [];
for(var i = 0; i < 10; i++){
//向数值内放数据
arr.push('我是第' + (i+1) + '条新闻内容内容内容');
}
// console.log(arr);
for(var i = 0;i < arr.length; i++){
aUl.innerHTML += '<li><a href="javascript:;">'+ arr[i] +'</a></li>';
}
}
</script>
</head>
<body>
<ul id="list">
<!-- <li></li> -->
</ul>
</body>
</html>
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634837.html