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>

posted @ 2020-03-21 21:46  JackieDYH  阅读(2)  评论(0编辑  收藏  举报  来源