Rushabh Shah
Rushabh Shah

Reputation: 131

jQuery input value not removing on page ready

Jquery:

$(document).ready(function()
            {
                $("input[type=search]").val('');
            })

HTML:

<input type="search" class="form-control input-xlarge input-lg input-inline" placeholder="" aria-controls="example">

Link:

http://vsss.co.in/Admin/index.php/GST/gst_list

Anyone can please help me why value not becoming blank when the page is ready. How can I solve this issue?

Upvotes: 1

Views: 92

Answers (2)

Parag Jadhav
Parag Jadhav

Reputation: 1899

Here is a working FIDDLE

$(document).ready(function() {
  //Option1
  alert($("input[type=search]").val());
  $("input[type=search]").val("");

  //Option2
  alert($("#yourId").val());
  $("#yourId").val("");
});

Upvotes: 2

Marco Salerno
Marco Salerno

Reputation: 5203

This is working:

$(document).ready(function()
            {
                $("input[type=search]").val('');
            })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="search" class="form-control input-xlarge input-lg input-inline" placeholder="" aria-controls="example" value="Does it works?">

Upvotes: 0

Related Questions