I need to do a function on Jquery that write in a div some HTML elements.
Code is this :
function loadAppartamenti() {
$('.profilo_2').empty();
$('.profilo_2').html("<label class='article_span'>Inserisci Zona (es. Via/Località)</label> /
<input id='art_1' class='article_input' /> /
<label class='article_span'>Costo (€ Mese)</label> /
<input id='art_2' class='article_input' /> /
<label class='article_span'>Disponibilità (Periodo In Mesi)</label> /
<input id='art_3' class='article_input' /> /
<label class='article_span'>Condizioni</label> /
<input id='art_4' class='article_input' /> /
<label class='article_span'>Servizi Presenti</label> /
<input id='art_5' class='article_input' />");
}
I need to clean the code as clean as possible, so i’ve aligned it (I go to the new line when i write a line).
I know that on Javascript i can do it, adding a / at the end of each line. But maybe i wrong remember. In fact if i run this code on Chrome, the console says “Uncaught SyntaxError: Unexpected token ILLEGAL”.
How can I fix this problem? I don’t want to write the code on 1 line 🙂
You need a backslash at the end of each line rather than a forward slash: