<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
window.onload = function (){
var oBtn = document.getElementById(‘btn1‘);
var oUl = document.getElementById(‘list‘);
var arr = [
‘山西省委附近多次爆炸 官方称尚不确定是恐怖袭击‘,
‘甘肃张掖明令禁止转基因 书记:无力辨别只能禁止‘,
‘多地制定雾霾预案限行限排被批治标不治本‘,
‘韩媒抱怨中国雾霾侵袭韩国 称其为"黑色灾难" ‘,
‘伊朗革命卫队高官在叙利亚当"志愿者"被杀(图)‘
];
/*
思路:
1、按钮找麻烦 (用户体验不太好)
2、先清空,再生成
3、判断
*/
var onOff = true;
oBtn.onclick = function (){
// oBtn.disabled = true;
// oBtn.style.display = ‘none‘;
// oUl.innerHTML = ‘‘;
// onOff = false; no!!!!
if( onOff ) {
// onOff = false; ok
for( var i=0; i<arr.length; i++ ){
oUl.innerHTML += ‘<li>‘ + arr[i] + ‘</li>‘;
}
// onOff = false; ok
}
onOff = false;
};
};
</script>
</head>
<body>
<input id="btn1" type="button" value="自动生成5条新闻" />
<ul id="list" style="border:1px solid red;"></ul>
<script>
alert( document.getElementById(‘list‘).style.border );
</script>
</body>
</html>