关于alert弹窗和逻辑顺序的问题
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<style>
.none{background:red;}
</style>
</head>
<body>
<div id="newapp" style="border:1px red solid;width:100px;height:100px;margin-bottom:100px;">
</div>
<div id="table2">
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
</div>
<textarea style="overflow:auto" id="tui"></textarea>
<input type="button" value="click" onclick="hid()"/>
</body>
<script type="text/javascript">
function hid(){
var nw = document.getElementById("newapp");
var che = document.getElementById("table2").getElementsByTagName("input");
var tui = document.getElementById("tui");
for (ic=0;ic<che.length;ic++){
if (che[ic].checked==false){
alert("请先选择应用")
break;
}
}
if (tui.value==""){
alert("请填写推荐语")
}
else{
nw.className="none";
}
}
</script>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<style>
.none{background:red;}
</style>
</head>
<body>
<div id="newapp" style="border:1px red solid;width:100px;height:100px;margin-bottom:100px;">
</div>
<div id="table2">
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
</div>
<textarea style="overflow:auto" id="tui"></textarea>
<input type="button" value="click" onclick="hid()"/>
</body>
<script type="text/javascript">
function hid(){
var nw = document.getElementById("newapp");
var che = document.getElementById("table2").getElementsByTagName("input");
var tui = document.getElementById("tui");
for (ic=0;ic<che.length;ic++){
if (che[ic].checked==false){
alert("请先选择应用")
break;
}
}
if (tui.value==""){
alert("请填写推荐语")
}
else{
nw.className="none";
}
}
</script>
</html> 展开
展开全部
我想楼主的意思应该是这样的:
<script type="text/javascript">
function hid(){
var nw = document.getElementById("newapp");
var che = document.getElementById("table2").getElementsByTagName("input");
var tui = document.getElementById("tui");
var flag=false;
for (ic=0;ic<che.length;ic++){
if(che[ic].checked){
flag=true;
break;
}
}
if(!flag){alert("请先选择应用");return false;}
if (tui.value==""){
alert("请填写推荐语")
return false;
}
else{
nw.className="none";
}
}
</script>
<script type="text/javascript">
function hid(){
var nw = document.getElementById("newapp");
var che = document.getElementById("table2").getElementsByTagName("input");
var tui = document.getElementById("tui");
var flag=false;
for (ic=0;ic<che.length;ic++){
if(che[ic].checked){
flag=true;
break;
}
}
if(!flag){alert("请先选择应用");return false;}
if (tui.value==""){
alert("请填写推荐语")
return false;
}
else{
nw.className="none";
}
}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询