Reputation: 83
I am trying to write JavaScript code in Tampermonkey
that will simulate entering search text in a dynamic (search results update with each letter typed) web site search box. The HTML for the search element is as follows:
<input class="billybudd" id="search" placeholder="Search"
autocomplete="off" type="search" value="" data-reactid="rotterdam">
I have made this work for other sites by using the following code:
$('#search').val('searchtext');
$('#search').change();
For this site, though, the search text box
updates with the 'searchtext'
value, but the dynamic search results are not triggered by the change()
method.
Any help with this would be greatly appreciated.
Upvotes: 1
Views: 1193
Reputation: 21769
I will jump to an empty pool here and do a wild guess, perhaps the event bound is input
and not change
so that each keypress will trigger the search functionality, try as follows:
$('#search').val('searchtext');
$('#search').trigger("input");
Upvotes: 1