javascript - Display result of js calculation in span -
i'm trying calculate in javascript , display result in <span></span>
. code i've got @ moment:
<script type="text/javascript"> window.onload = function() { function minus_number() { var first_number = '50'; var second_number = '30'; var result = parseint(first_number) - parseint(second_number); document.getelementbyid('spend').value = result; } }
and html
<p><i class="fa fa-truck"></i>want free delivery? spend <span id="spend"></span> free standard delivery</p>
it doesn't display result in span though, can tell me i'm doing wrong?
try this, call function using event listener
.
function minus_number() { var = document.queryselector("#spend"); var first_number = '50'; var second_number = '30'; var result = parseint(first_number) - parseint(second_number); a.innerhtml = result; } window.addeventlistener("load",minus_number());
Comments
Post a Comment