SKG SKG - 10 days ago 5
Javascript Question

Searching using Javascript/Jquery

On performing inspect element on input, I get:

<input class="gsfi" id="lst-ib" maxlength="2048" name="q" autocomplete="off" title="Search" type="text" value="" aria-label="Search" aria-haspopup="true" role="combobox" aria-autocomplete="both" dir="ltr" spellcheck="false" style="border: none; padding: 0px; margin: 0px; height: auto; width: 100%; background: url(&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D&quot;) transparent; position: absolute; z-index: 6; left: 0px; outline: none;">

Now if I do:
, I get input object as expected. But if I do:
$("#lst-ib").val("hello world!")
, I get an error:

Uncaught TypeError: $(...).val is not a function(…)

Same thing is happening with Can someone explain why is it happening and how can I search on these website by using


The reason is google doesn't use jQuery, so you can't use jQuery functions there.

try this

//change the input
document.getElementById("lst-ib").value = "What you want to find";
//submit form

It will change the search input as you expected.