Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple lines when using jQuery's .html method

Tags:

jquery

I would like to have multiple lines when I use jQuery's html method, like this:

$("#someID").html("     <h1>Headline 1</h1>     <h1>Headline 2</h1>     "); 

However this snippet of code does not work. Is there a way to use multiple lines when using jQuery's html method?

like image 594
timkl Avatar asked Dec 30 '11 06:12

timkl


People also ask

How do you write multiple lines of code in HTML?

Multiline Comments You can comment multiple lines by the special beginning tag <! -- and ending tag --> placed before the first line and end of the last line as shown in the given example below.

How do I print text on multiple lines in HTML?

As part of a form, the <textarea> tag creates a multiline text-entry area in the user's browser display. In it, the user may type a nearly unlimited number of lines of text.


1 Answers

use \ to escape new line chars.

$("#someID").html("\     <h1>Headline 1</h1>\     <h1>Headline 2</h1>\     "); 

View working example here: http://jsfiddle.net/amantur/yeDff/

like image 171
TheVillageIdiot Avatar answered Sep 29 '22 08:09

TheVillageIdiot