更新時(shí)間:2016年01月29日 09:27:30 作者:翱翔天地
整體思路是這樣的:判斷div內(nèi)部是否為空,如果為空js判斷屬性是否為空,給出無(wú)數(shù)據(jù)提示;否則顯示正常頁(yè)面js判斷屬性是否為空,下面給大家分享js判斷div內(nèi)容是否為空的方法,對(duì)判斷div內(nèi)容是否為空的相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
1、問(wèn)題背景
判斷div內(nèi)部是否為空,如果為空,給出無(wú)數(shù)據(jù)提示;否則顯示正常頁(yè)面
2、實(shí)現(xiàn)效果圖如下所示:
3、設(shè)計(jì)源碼
如何判斷DIV中的內(nèi)容為空 <script type="text/javascript" src="jquery-2.2.0.js"></script> <script type="text/javascript"> $(function(){ $("#content").append("
您好!"); $("#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>
以上所述是小編給大家介紹判斷DIV內(nèi)容是否為空的方法,希望對(duì)大家有所幫助。