RyeGuy RyeGuy - 1 year ago 79
jQuery Question

Element text content not changing on click

I am attempting to make a functional timer that counts down from 15 or 30. However I cannot get to the text value to change upon click of the 15 button. Can someone diagnose this issue?

Thanks in advance


<h1 id="timer"><time>00</time></h1>
<button id="fifteen">15 sec</button>

JavaScript or Jquery

var fifteen = document.getElementById('timer');

fifteen.onclick = fifteenRollback();

function fifteenRollback(){
h1.textcontent = "15";

Answer Source

Just do it using mentioned jQuery library:

$('#fifteen').on('click', function() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download