简体   繁体   中英

JQuery Error “Uncaught TypeError: $(…).placeholder is not a function” [on hold]

I experience this error:

jquery.js:3850 Uncaught TypeError: $(...).placeholder is not a function

My Code line is:

// Fix: Placeholder polyfill.
jQuery('form').placeholder();

How to solve it? Greetings

I assume you are trying to use a jQuery plugin which is the, or is similar to HTML5 Placeholder jQuery Plugin .

If that is case, then a possible cause for the error you are receiving could be that the plugin itself is not installed/included in the Web project. Plugins are not part of the jQuery library, they are rather extensions and they only extend the jQuery if they are loded on the page.

Also, in case, the Plugin I have mentioned is the one you are using, the placeholder() method needs to be called on the input and textarea elements like this:

$('input, textarea').placeholder();

OR, if you would like to add your custom CSS class to style the placeholder for the input and textarea elements like this:

$('input, textarea').placeholder({ customClass: 'my-placeholder' });

Give this a try and if this doesn't work, share with us more details about which plugin you're trying to use. Eventually a link to the documentation website would be very helpful and we could advise you accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM