Quick question to string handling
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>')
精彩评论