Chris Simpson
Chris Simpson

Reputation: 8000

JQuery - disable inputs that haven't been added yet

I want to disable inputs with a particular class, however I want to do this for any future inputs added to the page.

live() and delegate() can bind to events on elements that don't exist yet. Is there some sort of selector that can run some code on future elements in the same way?

Upvotes: 0

Views: 180

Answers (1)

gearsdigital
gearsdigital

Reputation: 14225

You could try to build your own custom event and bind it to your document. So every time you create an input you cann call your event. With your own event you are free to add the disabled attribute to all elements with your specific class.

With custom jQuery event you can add extremly complex behaviors to your document.

Upvotes: 1

Related Questions