I am trying to append a new line using this this code. I have tried \n and only \ but no solution. What can I do now?
function infC(name) {
jQuery("#dialog").text(information_by_equipment[name][1]).append(information_by_equipment[name][2]);
event.stopPropagation();
}
I am trying to append a new line using this this code. I have tried \n and only \ but no solution. What can I do now?
function infC(name) {
jQuery("#dialog").text(information_by_equipment[name][1]).append(information_by_equipment[name][2]);
event.stopPropagation();
}
Share
Improve this question
edited Jan 23, 2016 at 20:36
Praveen Kumar Purushothaman
167k27 gold badges213 silver badges259 bronze badges
asked Jan 23, 2016 at 20:26
user6135434user6135434
0
3 Answers
Reset to default 10The .append()
appends HTML. You need to use <br />
:
jQuery("#dialog")
.text(information_by_equipment[name][1])
.append("<br />" + information_by_equipment[name][2]);
$(document).ready(function(){
$("#dialog").append((information_by_equipment[name][1] + "<br>" + information_by_equipment[name][2]);
});
This should solve your problem. Simply add a <br>
to enter a new line between your "lines".
If the above solutions are not working try this one.
jQuery("#dialog")
.text(information_by_equipment[name][1])
.append(" " + information_by_equipment[name][2]);
Line Feed and
Carriage Return