Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript line-break not working

I have this really big text where I want to add line breaks in order to look better on my application. I have tried using

"<br>", "\n"

to cut the text in pieces. I have ven tried to change the width of the span but nothing seems to be working. What am I doing wrong? Any help appreciated.

<span id="instr" style="color: white; font-size: 15pt;"></span>

<script type="text/javascript">
function instructions(){
....

document.getElementById("instr").textContent = "Really biiiiiiiiiiiiiiiiiiiiiiiiig text here";

}
</script>
like image 399
niaoy Avatar asked Jul 09 '26 09:07

niaoy


1 Answers

To set <br /> line breaks you need to use innerHTML property:

document.getElementById("instr").innerHTML = "Really<br />biiiiiiiiiiiiiiiiiiiiiiiiig<br/ >text here";
like image 62
VisioN Avatar answered Jul 11 '26 21:07

VisioN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!