Objiect

导航

关于判断

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1 { width:240px; height:200px; border:1px solid #333; background:#f1f1f1; padding:10px; }
</style>
<script>

/*
if(){} 在做这事之前,有个条件
if(){}else{} 2件事,根据条件,选一个来做
if(){}else if(){}else if(){}else if(){}
if(){}else if(){}else if(){}else if(){}else{}
*/

window.onload = function (){
var oDiv = document.getElementById('div1');
var oStrong = document.getElementById('strong1');
var oText = document.getElementById('text1');
var oBtn = document.getElementById('btn1');

oBtn.onclick = function (){
if( oText.value == '' ){
alert('没说话呢,别急着点~~');
}else{
oDiv.innerHTML += oStrong.innerHTML + oText.value + '<br />';
oText.value = '';
}
};
};
</script>
</head>

<body>

<div id="div1"></div>
<strong id="strong1">张三:</strong>
<input id="text1" type="text" />
<input id="btn1" type="button" value="提交" />

</body>
</html>

posted on 2017-05-24 10:39  BigBiuBiu  阅读(120)  评论(0编辑  收藏  举报