Mattias
Mattias

Reputation: 3169

How to call the iOS search button with javascript/Jquery?

I've got an searcharea where I've used

<form><input name="search"/></form>

which enables and shows the search button on iOS mobile keyboard.

My question is now, how can i find this search button in code so that i could add an onclick="(callFunction)" for example like i would be able to do if I had created an button myself. Any help or input highly appreciated, thanks!

Upvotes: 3

Views: 1447

Answers (1)

Irvin Dominin
Irvin Dominin

Reputation: 30993

I think you are using and type="search", so you can attach an event handler to the search event like:

$('input[type=search]').on('search', function () {
    // search logic
});

or:

<input type="search" name="search" onsearch="OnSearch(this)"/>

Doc:

Occurs when the user presses the ENTER key or clicks the 'Erase search text' button (x) in an input:search field.

Ref: http://help.dottoro.com/ljdvxmhr.php

Demo: http://jsfiddle.net/rb684u8o/

Upvotes: 1

Related Questions