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();
}
The .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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.