开发者

Quick question to string handling

开发者 https://www.devze.com 2023-02-01 23:38 出处:网络
I’m pretty new to JavaScript, so I hope you could help me. I have a top navigation menu 开发者_运维百科with text on image buttons. When the text is just one word everything is fine. When it consists

I’m pretty new to JavaScript, so I hope you could help me.

I have a top navigation menu 开发者_运维百科with text on image buttons. When the text is just one word everything is fine. When it consists of two words I want to cut the string on the space character and put the second word into the second line.

I know I can find the character with the indexof method. But how would I go from there?

Thanks


Replace ' ' with '<br>'.

s = s.replace(/ /g, '<br>')
0

精彩评论

暂无评论...
验证码 换一张
取 消