mathiasbynens / jquery-placeholder

A jQuery plugin that enables HTML5 placeholder behavior for browsers that aren’t trying hard enough yet
https://mths.be/placeholder
MIT License
3.98k stars 1.34k forks source link

The plugin will not work when input(textarea) is hidden #283

Closed animabear closed 8 years ago

animabear commented 8 years ago

I check the source code and found this:

placeholder = $.fn.placeholder = function(options) {
...
return this.filter((isInputSupported ? 'textarea' : ':input') + '[' + (debugMode ? 'placeholder-x' : 'placeholder') + ']')
                .not('.'+settings.customClass)
                .not(':radio, :checkbox, :hidden') // here

so if input or its ancestor element is hidden when init (it's a normal scene),it won't work.

Could you tell me why use :hidden here ? I make a small changes:

.not(':radio, :checkbox, [type="hidden"]')
amerikan commented 8 years ago

@animabear you're right, [type="hidden"] should be used and not :hidden. If you can do a pull request I can merge, if not I can do it myself later.

amerikan commented 8 years ago

@animabear I have published a new release with this fix.

animabear commented 8 years ago

@amerikan ok,thanks