How we can get the value entered in search API autocomplete field in jQuery? I got a requirement to send the search text to GTM for tracking purpose. I have a field which is from search api autocomplete module. I am not getting the value in jQuery on click of submit button. I tried like below but no success:

var search_key = $('.path-frontpage .ui-autocomplete-input').attr('value');


Can anybody implemented such thing. Please help

DOM:

&lt;input placeholder="Search MyP&amp;amp;O" data-drupal-selector="edit-keywords" data-search-api-autocomplete-search="search" class="form-autocomplete form-text form-control ui-autocomplete-input" data-autocomplete-path="/search_api_autocomplete/search?display=page&amp;amp;&amp;amp;filter=keywords" type="text" id="edit-keywords" name="keywords" value="" size="30" maxlength="128" autocomplete="off"&gt;
This works for me:

var search_key = $('.path-frontpage .ui-autocomplete-input').val();