Jacob
Jacob

Reputation: 1004

How do you force focus on an HTML input element?

In jQuery you can force focus onto an input using something along the lines:

$("input[name='text']").focus();

But how is it done in ClojureScript (preferable something Enfocus friendly) ?

Upvotes: 3

Views: 1929

Answers (2)

Stephen Nelson
Stephen Nelson

Reputation: 939

Without using enfocus, you can do this by calling javascript functions, e.g.

(-> js/document (.querySelector "input[name='text']") (.focus))

or using .. threading:

(.. js/document (querySelector "input[name='text']") (focus))

Upvotes: 3

Jacob
Jacob

Reputation: 1004

I must have been very tired, the following works :)

(ef/at "input[name='text']" (focus))

Upvotes: 1

Related Questions