1

Here I have an example:

$('#key').on('click', function(){
  $('.task').html("<button id='key'>Button</button>"+Date());
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='task'>
  <button id='key'>Button</button>
</div>

How I can apply javascript for overwriting element and get different time for each button press?

Roman
  • 703
  • 1
  • 6
  • 11

1 Answers1

0

Clearly there is no need to ovveride button here. Do not ovveride button. Use a span for date.

$('#key').on('click', function(){
  $('.datestr').html(Date());
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='task'>
  <button id='key'>Button</button>
  <span class='datestr'></span>
</div>
Suresh Atta
  • 118,038
  • 37
  • 189
  • 297