Home >Web Front-end >JS Tutorial >Solution to style problem when browser parses html generated by js_javascript skills

Solution to style problem when browser parses html generated by js_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:54:131012browse

The function I implemented is to add tags to the end of the tag list without refreshing. See the second line in the picture below. There is obviously something wrong with the style
Solution to style problem when browser parses html generated by js_javascript skills
I repeatedly checked the html of the chrome console The structures are all the same. I have carefully compared them in IE and FF, and there is still no difference. See the picture below
Solution to style problem when browser parses html generated by js_javascript skills
The same html structure, the same style, but the displayed styles are very different. I ran out of ideas for a while, like a headless fly. I simply copied the html under the console to notepad for comparison, and I saw some clues, as shown in the picture below. The left side is the html generated by js, and the right side is the html in the page (.aspx)
Solution to style problem when browser parses html generated by js_javascript skills

The reason for the style difference may be the lack of line breaks on the left side. I put the characters in each line Newline character added at the end" ”, so the style problem is solved

Copy code The code is as follows:

var html =
[
"
  • n".format(catId),
    "
    n",
    "n".format(catId),
    "{0}n".format(catName),
    "[edit][Delete ]n".format(catId),
    "
    ",
    "
    n",
    "n".format(catName),
    "n".format(catId),
    " n".format( catId),
    "
    n",
    "
  • n"
    ].join("");

    After a long time Thinking, solving a problem, so happy!
    Author: Qingliuyu
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn