Change text on the page

See more about:

A common output pattern is to change existing text on the page. Try it. Enter a number and click the button.

Number:

Double:

Here is the important code:

<p>Double: <span id="double_out"></span></p>
...
$("#double_out").text(x);

Look at line 1. The <span> is where the output it going to go. It has an id so JavaScript code can refer to it. The <p> is the container of the entire output area.

Line 3 puts data into the <span>. Whatever value x has is shown.


Lessons

How to...


Dogs