Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

line break inside <p> tags when using Jquery.text()

I am trying to do something like this:

<p> Line 1 <br/> Line 2 <br/> </p>

This does not work, but is what i'm trying to do possible?

Edit: more info

i am executing this line of code: $("#textDialogBox").text("test<br />test2");

where #textDialogBox is <p id = "textDialogBox">This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>

But when I open the dialog box the
shows up as text, rather than a line break.

like image 875
kralco626 Avatar asked Dec 11 '10 19:12

kralco626


People also ask

How do you add a line break in P tag?

To use this shortcut, move to the text cursor to where you want the new line to begin. Then, press and hold the Shift key, and press the Enter key. If this keyboard shortcut does not work, it is likely only possible to enter a new line by manually inserting a line break ("<br>" tag) in the document's HTML code.

How do you remove a line break after P tag?

In this event, try p {display:inline}; to modify the display property. The preceeding CSS will remove the line-break by default. Depending on your criteria, you can modify it to reference a specific element or class. p {display:inline;} is full correct code to deactivate line feed with css of tag p.

Which tag is used for text break line?

<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

Does tag will create a line break?

You can insert line breaks in HTML with the <br> tag, which is equivalent to a carriage return on a keyboard.


1 Answers

Have this instead:

$("#textDialogBox").html("test<br/>test2");

The text() method of jQuery will "destroy" any HTML given to it, and this includes <br /> as well.

like image 171
Shadow Wizard Hates Omicron Avatar answered Oct 13 '22 23:10

Shadow Wizard Hates Omicron