Javascript Variable and document write -


i'm new javascript , trying learn basics

i'm making webpage add's totals etc , right start i'm having problem.

i'm looking @ videos on lynda.com , i've searched net.

it's simple i'm trying do.

i have variable set 30 , want display on page.

var points = 30; document.write(points); 

i had 30 in double , single quotes didn't work.

my html

<p id="points"></p> 

what want happen want variable display on site. in case want 30 display on site.

it's not @ moment.

any great. thanks.

the correct code is:

var points = 30; document.getelementbyid('points').innerhtml = points; 

use innerhtml change html code , use innertext change text.

maybe forgot implement script:

<script src="path/and/yourscriptname.js"></script> <p id="points"></p> 

Comments