Analysis on the causes and solutions for getting errors in DIV content, analysis of div causes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.