I am trying to simulate click on an input box. When its clicked manually, a drop down auto suggestion box appears as suggestions about past searches. However, when I try to simu
If you want to use pure/native javascript, you can use the onfocus attribute of the input
element to call a Js function.
<script>
function showButton(){
document.getElementById('mybutt').style.display = "block";
}
</script>
<body>
<input id="myinp" type="text" placeholder="place" onfocus="javascript:showButton()"/>
<button id="mybutt" style="display:none;">OK</button>
</body>
In the above file, you should see the "OK" button appear when you click on the input field.
You need to .focus() instead of .click()
document.getElementbyClassName("gb_cf")[0].focus(); //or
document.getElementbyId("gs_taif50").focus();