Summary of ways to wrap labels in innerHTML_javascript tips
When using innerHTML to generate a structure, in order to make the structure look clear, you can add a backslash at the end of each line to maintain the original html structure without squeezing the tags together
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>innerHTML中标签可以换行的方法</title> </head> <body> <script> //function fnNew(){ var sHtml = ''; for(var i = 0; i < 2; i++){ sHtml += '<li class="in">\ <div class="in-con">\ <button class="in-btn_s">显示</button>\ <button class="in-btn_h">隐藏</button>\ </div>\ <div class="in-show">第'+ i +'种方法:'+ data[i]+'</div>\ </li>'; } oList.innerHTML = sHtml; } </script> </body> </html>
I just learned Brother Shiba’s Javascript today. Speaking of the use of innerHMTL, the teacher said that the tags inside did not wrap. I felt that it would be inconvenient for me to operate it in the future, so I copied this code and asked how to do it. Friends who have programmed
function t2(){ var cont = document.getElementById('container'); var htmlcode = "<p><ul><li><span>东</span></li><li>南</li><li>西</li><li>北</li></ul></p>"; cont.innerHTML = htmlcode;
be written so that it can be line-wrapped?
<p><ul><li><span>东</span></li><li>南</li><li>西</li><li>北</li></ul></p>
But hard work pays off, someone finally told me the method See the code below
var htmlcode = "<p> \ <ul> \ <li><span>东</span></li> \ <li>南</li> \ <li>西</li> \ <li>北</li> \ </ul> \ </p>";
That is, each time the code needs to be wrapped, there is one more line break. (No special tricks, I just feel more comfortable writing code this way)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In the process of using Excel, we have to perform many different operations. Sometimes we need to wrap a line in a cell. So what exactly do we need to do to wrap a cell? Let’s take a look at how to wrap lines in a computer excel table. [Collection of excel table operation methods] How to wrap rows in excel table? Answer: You can do this by automatically wrapping rows and setting cell formats. 1. Automatic line wrapping 1. We select the area that needs to be wrapped in the table and click [Automatically wrap] on the [Start] page; 2. Then we adjust the width of column A to an appropriate value; 2. Set the cells Format 1. First, we select the area that needs to be wrapped, right-click the mouse, and click [Set Cell Format]; 2. Then in the pop-up

Many users use the BarTender software in their offices. Recently, some new users have asked how to wrap lines in BarTender. Below, the editor will bring you the method of wrapping lines in BarTender. Let us take a look below. 1. In BarTender, click the Create Text button in the toolbar, select Create Single Line Text, and enter the text content. 2. Double-click the created text object to open the text properties dialog box. Switch to the "Text Format" tab and select "Paragraph" for "Type" on the right. 3. Click Close, adjust the size of the text box or enter more text, or wrap the text according to actual requirements.

Wrapping lines in cells in Apple's Excel Apple's Excel software is a powerful spreadsheet tool that provides many convenient functions to help users with data processing and analysis. When using Excel, sometimes we need to enter multiple lines of text in cells to better organize and present the data. However, since Excel for Apple computers is slightly different from the Windows version of Excel, the method of wrapping lines is also different. In the Windows version of Excel, we can directly

1. Press the space bar multiple times, move the cursor to the far right, and then enter text to wrap the line. 2. When you need to break a line, click the microphone icon on the keyboard and the voice will say [Line break]. 3. In the memo usage scenario, there is a [Line Break] option in the input method, which can be used to achieve line break by copying. 4. Download other third-party input methods from the app store to use.

PyCharm is a powerful Python integrated development environment, and its automatic line wrapping function can help developers write code more efficiently. This article will introduce how to quickly master the automatic word wrapping function in PyCharm and provide specific code examples. 1. Enable the automatic word wrapping function. In PyCharm, the automatic word wrapping function is not enabled by default and needs to be manually set before it can be used. The specific steps are as follows: Open PyCharm and enter File->Settings;

Go language is a modern, efficient and concise programming language that is widely used in software development in various fields. In the Go language, outputting text with newlines is very simple and can be achieved by using the Println function provided by the fmt package. Below we will introduce in detail how to output text with line breaks in Go language, as well as related code examples. In the Go language, if you want to output text with newlines, you can use the Println function provided by the fmt package. The Println function will output text in

Detailed explanation of how to replace newlines in PHP In PHP development, sometimes we need to replace or process newlines in strings. Line breaks may be expressed differently on different platforms, so they need to be processed uniformly to ensure that strings display consistently in different environments. This article will introduce in detail how to replace newlines in PHP, including common newline characters and specific code examples. 1. Common newline characters In different operating systems, the representation of newline characters may be slightly different. The main newline characters include: Windo

Excel is a powerful spreadsheet software that can help us process various data and information. When using excel, sometimes we need to adjust the layout of the table, including row wrapping and column order. Below, I will introduce in detail how to wrap rows and adjust the order of columns in Excel. 1. Line break 1. Use line break: In excel, we can use line break to achieve line break. The specific operations are as follows: a. Select the cell or cell range that needs to be wrapped. b. Enter the text you want to wrap in the selected cell.
