Reputation:
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();
}
Upvotes: 7
Views: 18736
Reputation: 829
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
Upvotes: 0
Reputation: 1587
$(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".
Upvotes: 1
Reputation: 167250
The .append()
appends HTML. You need to use <br />
:
jQuery("#dialog")
.text(information_by_equipment[name][1])
.append("<br />" + information_by_equipment[name][2]);
Upvotes: 10