By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Button that creates carriage return

P: 3
I need to create a button that when clicked, starts a new line on the webpage.

At the top of my page, there are buttons. Each time a button is clicked, a word appears, one after the other. I need this button to start a new line, so after this button is clicked, the buttons at the top, when clicked, will output their words in a new line below the previous ones. I've been experimenting with different coding for this button, but so far, nothing has worked.
Apr 17 '15 #1
Share this Question
Share on Google+
5 Replies


Dormilich
Expert Mod 5K+
P: 8,639
I've been experimenting with different coding for this button, but so far, nothing has worked.
so what have you tried? maybe you were almost there.
Apr 17 '15 #2

P: 3
Expand|Select|Wrap|Line Numbers
  1. <input type="button" value="Return"
  2.     onclick="document.getElementById('outputDiv').innerHTML=
  3.     <\r>;">
  4. <div id="outputDiv"></div>
This is one of the codes I've tried. Basically, I can't figure what to put after innerHTML.
Apr 17 '15 #3

Dormilich
Expert Mod 5K+
P: 8,639
try \r (without < and >)
Apr 18 '15 #4

Rabbit
Expert Mod 10K+
P: 12,347
You're trying to change the innerHTML to add a carriage return? In HTML, a line break is represented by the tag <br>. But also, you're replacing the entire innerHTML with that, you need to append to it, not replace it.
Apr 18 '15 #5

P: 3
Expand|Select|Wrap|Line Numbers
  1. <input type="button" value="Return"
  2.     onclick="document.getElementById('outputDiv').innerHTML=
  3.     document.getElementById('outputDiv').innerHTML + \br;">
  4. <div id="outputDiv"></div>
Should it be something more along the lines of this?
Apr 18 '15 #6

Post your reply

Sign in to post your reply or Sign up for a free account.