Clearing input value issue

in my app i clear the input using this code:
$("#element").next().trigger('click');
it does clear the input and hide the x button. but the issue im facing is the keyboard are shown for a second…

how can i prevent the keyboard from showing when i want to reset the input?

$("#element").val('').trigger('change');

i just tried that. it doesn’t remove the x button.

wrapping the clearing code with setTimeout did the trick in the page:afterout event