How to resolve style issues in html generated by js through a browser

Source: Internet
Author: User

The function I implemented is to add a label and add it to the label list without any additional efforts. For details, see the second line in. The style is obviously incorrect.

I repeatedly checked the html structure of the chrome console, which is the same. I have carefully compared IE and FF, but there is no difference. See

In the same html structure and style, the style displayed is very different. At the moment, there is no idea, like a headless fly. Simply copy the html in the console to notepad ++ for comparison. Html generated by js on the left and html in. aspx on the right


The reason for style differences may be that there is a lack of line breaks on the left. I added the line break "\ n" at the end of each line character, so that the style problem can be solved.
Copy codeThe Code is as follows:
Var html =
[
"<Li id = \" litem _ {0} \ "> \ n". format (catId ),
"<Div> \ n ",
"<Span class = \" checkbox \ "> <input type = \" checkbox \ "name = \" cbItem \ "value = \" {0 }\ "/> </ span> \ n ". format (catId ),
"<Span class = \" name \ "> {0} </span> \ n". format (catName ),
"<Span> <a href = \" javascript: void (0); \ "onclick = \" Blog. cat. edit ({0}); \ "> [edit] </a> <a href = \" javascript: void (0); \ "onclick = \" Blog. cat. delCat ({0}); \ "> [delete] </a> </span> \ n ". format (catId ),
"</Div> ",
"<Div style = \" display: none; \ "> \ n ",
"<Span> <input type = \" text \ "value = \" {0} \ "/> </span> \ n". format (catName ),
"<Span> <button type = \" button \ "class = \" button \ "onclick = \" Blog. cat. setCat ({0}); \ "> OK </button> </span> \ n ". format (catId ),
"<Span> <button type = \" button \ "class = \" button \ "onclick = \" Blog. cat. cancel ({0}); \ "> cancel </button> </span> \ n ". format (catId ),
"</Div> \ n ",
"</Li> \ n"
]. Join ("");

After a long time of thinking, I am so happy to solve a problem!
Author: qingliuyu

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.