如何判断DIV中的内容为空
2017-06-27 13:49
253 查看
如何判断DIV中的内容为空
1、问题背景
判断div内部是否为空,如果为空,给出无数据提示;否则显示正常页面
2、设计源码
[java] view
plain copy
print?
<!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>如何判断DIV中的内容为空</title>
<script type="text/javascript" src="jquery-2.2.0.js"></script>
<script type="text/javascript">
$(function(){
$("#content").append("<div id='dv'>您好!</div>");
$("#btn").click(function(){
var content = $("#content").html();
var noContent = $("#no_content").html();
if(content == null || content.length == 0)
{
alert("content:"+conten);
}
if(noContent == null || noContent.length == 0)
{
alert("noContent:"+noContent);
}
});
});
</script>
</head>
<body>
<div id="content"></div>
<div id="no_content"></div>
<input type="button" id="btn" value="判读DIV为空"/>
</body>
</html>
3、实现结果
1、问题背景
判断div内部是否为空,如果为空,给出无数据提示;否则显示正常页面
2、设计源码
[java] view
plain copy
print?
<!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>如何判断DIV中的内容为空</title>
<script type="text/javascript" src="jquery-2.2.0.js"></script>
<script type="text/javascript">
$(function(){
$("#content").append("<div id='dv'>您好!</div>");
$("#btn").click(function(){
var content = $("#content").html();
var noContent = $("#no_content").html();
if(content == null || content.length == 0)
{
alert("content:"+conten);
}
if(noContent == null || noContent.length == 0)
{
alert("noContent:"+noContent);
}
});
});
</script>
</head>
<body>
<div id="content"></div>
<div id="no_content"></div>
<input type="button" id="btn" value="判读DIV为空"/>
</body>
</html>
3、实现结果
相关文章推荐
- 如何判断DIV中的内容为空
- 如何判断const修饰的内容?
- 如何用js控件div的滚动条,让它在内容更新时自动滚到底部?
- java中如何判断String中的内容是否为数字?
- 如何让div中的内容垂直居中
- AceyOffice教程--如何判断单元格的内容
- 如何让DIV在内容不固定的情况下宽度刚好显示完内容
- 如何让div中的内容垂直居中
- 如何让div中的内容垂直居中
- java中如何判断String中的内容是否为数字?
- android 的ListView中,如何判断其内容已滚动到最顶部或者最底部
- 如何判断文件内容是否相同
- CSS相邻选择器(>)选择子元素而不包含该子元素的子元素,及如何让DIV中的内容垂直居中
- 如何让2个并列的div根据内容自动保持同等高度
- 如何使div中的内容上下左右居中?
- 正则表达式的贪婪模式和非贪婪模式,如何取div ,li 标签的循环内容,采集别人网站的内容
- 如何让div中的内容垂直居中
- 如何判断textbox里面的内容是整数?? C#
- android 的ListView中,如何判断其内容已滚动到最顶部或者最底部?
- js如何判断textarea输入的内容不能为空