Keith Keith - 2 years ago 63
Javascript Question

Restoring placeholder value to a search box after reset has been clicked

I am editing some javascript that has a search box with a variable as follows

var secondSearchTerm = $('#2nd-search').val();

In the HTML code '2nd-search' has a placeholder 'Enter search term'

I also have a reset button that clears the search as follows:

$("#2nd-reset-btn").on("click", function () {
return myNetwork.resetSecondSearch();

What I would like to do is to get the search box to re-populate with the placeholder when reset is clicked. Right now the last entered term remains in the search box.

Any ideas on how I can edit the code to do this?

Many thanks!

Answer Source

hi refer this link


// Add your javascript here

$("#reset").on("click", function () {     
   return $('#username').val('');



<input type="text" name="name"  id = "username" placeholder="uname"/>
<button id="reset">Reset </button>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download