Home >Web Front-end >JS Tutorial >How to determine whether jquery div is empty
How to determine whether jquery div is empty: first introduce jQuery.min.js into the html page; then introduce jQuery and searchNull.js; finally add the id attribute to any div in the html page as " no_content" can realize the judgment.
The operating environment of this tutorial: windows7 system, jquery1.2.6 version, DELL G3 computer.
Recommended: jquery video tutorial
How to use jQuery to determine whether a div is empty
1. In the html page Introduce jQuery.min.js, it is best to use version 1.2 or above
2. The searchNull.js code is as follows
function validate() { //var content = $("#content").html(); var noContent = $("#no_content").html(); // if (content == null || content.length == 0) { // alert("content:" + conten); // } if (noContent == null || noContent.length == 0) { $("#no_content").append("<p>对不起,没有相关的查询结果</p>"); alert("对不起,没有相关的查询结果"); window.location.href='/Shop'; } } window.onload = function () { validate(); }
3. The usage is as follows
First introduce jQuery and searchNull .js
Add the id attribute to no_content on any div in the html page
Example:
<div id="no_content"> </div>
The above is the detailed content of How to determine whether jquery div is empty. For more information, please follow other related articles on the PHP Chinese website!