-6

function incrementValue() {
  var value = parseInt(document.link('number').value, 10);
  value = isNaN(value) ? 0 : value;
  value++;
  document.link('number').value = value;
}
<div class="link">
  <a onclick="increasenumber()" class="font1"><a href="#"> random text here </a>

it does not show the number how do I make the number show?

1
  • 1
    In your onclick you call increasenumber but the function is named incrementValue
    – j08691
    Commented Jul 7 at 17:43

1 Answer 1

0

I'm not sure where did you get that syntax, but almost everything is wrong:

  1. div tag is not closed
  2. two a tags, one of them is not closed
  3. in onclick you're calling increasenumber, but function name is incrementValue
  4. etc... etc...

function increasenumber()
{
    var value = parseInt(document.getElementById('number').innerText, 10);
    value = isNaN(value) ? 0 : value;
    value++;
    document.getElementById('number').innerText = value;
}
<div id="number"></div>
<a onclick="increasenumber()" class="font1">random text here </a>

2
  • Why do you use var instead of let? Is there a specific reason behind this decision?
    – jason
    Commented Jul 7 at 16:42
  • 2
    @jason because it was in original code Commented Jul 7 at 16:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.