Analysis on the causes and solutions for getting errors in DIV content, analysis of div causes
1. Error description
2. Error cause
Because the element is added to the div, append () is used ();
$ ("# DivStyle"). append ("<div> <label> _ data [I]. name </label> </div> ");
The append contains dynamic data. When the request data is empty, obtain and determine the content in the div:
Var divContent = $ ("# divStyle" ).html (); if (divContent = null | divContent. length = 0) {$ ("# divStyle "). append ("<div> </div> ");}
When the judgment is made, it never enters the if, and then uses the console for debugging. Even if there is no data div, there are many spaces and line breaks in it.
3. Solution
(1) Use JS hiding method
When the requested data is null, no data is displayed. Otherwise, no data is hidden;
(2) request data using JsViews
The above article introduces the Cause Analysis and Solution for getting errors in the internal content of the DIV, hoping to help you.
Articles you may be interested in:
- Javascript implements automatic circular scrolling of text or images inside the div