首页 > 代码库 > 关于判断
关于判断
<!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 =http://www.mamicode.com/= ‘‘ ){
alert(‘没说话呢,别急着点~~‘);
}else{
oDiv.innerHTML += oStrong.innerHTML + oText.value + ‘<br />‘;
oText.value = http://www.mamicode.com/‘‘;
}
};
};
</script>
</head>
<body>
<div id="div1"></div>
<strong id="strong1">张三:</strong>
<input id="text1" type="text" />
<input id="btn1" type="button" value="http://www.mamicode.com/提交" />
</body>
</html>
关于判断