PiTheNumber
PiTheNumber

Reputation: 23542

jQuery: Clear input field as soon as loaded

I have an input field I would like to clear it as soon as possible. If I put my script into the DOM is not loaded. If I use document ready the input field was already visible for some time.

With .on() I can only react to events and $(document).on('DOMNodeInserted', func) does not include inital DOM elements.

Also I can't place the JavaScript inline only as included javascript file.

Is there any way to get the input field fast?

Upvotes: 0

Views: 92

Answers (3)

some_vlad
some_vlad

Reputation: 1

If display: none; is not a solution, try making text color similar to background-color of this input. And remove that rule when needed.

Upvotes: 0

Andika Tanuwijaya
Andika Tanuwijaya

Reputation: 191

In my understanding, you are talking about clearing a text field or something like that which the document will have at least 1 of that field and there is a/any event that will append similar text field to the document?

on load event and other similar event are not supported by event delegation

source

Upvotes: 0

Ele
Ele

Reputation: 33726

You can apply the CSS: display:none to the field.

After clear the field, remove the CSS: display:none

Hope this helps"

Upvotes: 2

Related Questions