I have a couple of code snippets. Basically, I want to need that when a user clicks on the button the output which comes should be delay by 2-5second. more convenient if text come please wait... on clicking the button(but not in the button text). or "loading image" like preloader.
Any help/suggestion please
function yes() {
var button = document.getElementById('test');
var name = document.getElementById('name');
var age = document.getElementById('age');
var location = document.getElementById('location');
var str = 'Hello! <p> My name is Ashish</p><p>How Are You: ' + name.value +
'';
document.getElementById('test').innerHTML = str;
};
<label>
Your Name:
<input id="name" />
</label>
<br />
<button onclick="yes()">Test</button>
<p id="test"></p>