How to support placeholder attribute in IE8 and 9
You could use this jQuery plugin:
https://github.com/mathiasbynens/jquery-placeholder
But your link seems to be also a good solution.
How to support placeholder attribute in IE8?
You can always use additional plugins like
https://github.com/mathiasbynens/jquery-placeholder
https://github.com/jamesallardice/Placeholders.js
http://jamesallardice.github.io/Placeholders.js
Any of this will work :)
I suggest the first one. It has worked for me !
The Last 2 doesnt need any JQuery !
Possible duplicate of -> How to support placeholder attribute in IE8 and 9
Placeholder in IE9
HTML5 Placeholder jQuery Plugin
- by Mathias Bynens (a collaborator on HTML5 Boilerplate and jsPerf)
https://github.com/mathiasbynens/jquery-placeholder
Demo & Examples
http://mathiasbynens.be/demo/placeholder
p.s
I have used this plugin many times and it works a treat. Also it doesn't submit the placeholder text as a value when you submit your form (... a real pain I found with other plugins).
Placeholder attribute not supported in IE. Any suggestions?
You're right that IE8 doesn't support the placeholder
attribute. placeholder
is part of the HTML5 spec, and IE8 was released a long time before HTML5 was thought of.
The best way to deal with it in a seamless manner is to use a tool like Modernizr to detect whether the browser has support for the placeholder feature, and run a JS polyfill script if it isn't supported.
if(!Modernizr.input.placeholder) {
//insert placeholder polyfill script here.
}
There are numerous placeholder polyfill scripts out there to download. Pick one which makes use of the placeholder
attribute so that you only need to define the placeholder string in one place for all browsers. Here's one you could try: http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
Hope that helps.
Placeholder attribute not supported in IE. Any suggestions?
You're right that IE8 doesn't support the placeholder
attribute. placeholder
is part of the HTML5 spec, and IE8 was released a long time before HTML5 was thought of.
The best way to deal with it in a seamless manner is to use a tool like Modernizr to detect whether the browser has support for the placeholder feature, and run a JS polyfill script if it isn't supported.
if(!Modernizr.input.placeholder) {
//insert placeholder polyfill script here.
}
There are numerous placeholder polyfill scripts out there to download. Pick one which makes use of the placeholder
attribute so that you only need to define the placeholder string in one place for all browsers. Here's one you could try: http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
Hope that helps.
Placeholder attribute on input tags for IE?
I wrote a jQuery plugin a while back that will add placeholder support to any browser that does not support it.
Placeholder Text in IE
Placeholder attribute on input tags for IE?
I wrote a jQuery plugin a while back that will add placeholder support to any browser that does not support it.
Placeholder Text in IE
Javascript placeholder for IE8 is not working
Your script is running to early. You need to use the document ready event to launch the script, or move it to the bottom of the page. I prefer the document ready event. See below:
<script type="text/javascript">
$(function() {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur().parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
});
</script>
Related Topics
How to Use Tel: With * (Star, Asterisk) or # (Hash, Pound) on Ios
Full Width Backgrounds on Outlook '07/'10/'13
What Are the Allowed Tags Inside a ≪Li≫
How to Set Default Value to the Input[Type="Date"]
How Does This CSS Produce a Circle
What Are the Different Doctypes in HTML and What Do They Mean
Jquery: 'Uncaught Typeerror: Illegal Invocation' at Ajax Request - Several Elements
Changing <Select> Highlight Color
Word Wrap Options in a Select List
Space Between Nowrap Inline Blocks
Color of Stacked Semi-Transparent Boxes Depends on Order
Difference Between Width:100% and Width:100Vw
Scroll Particular Div Contents with Browser's Main Scrollbar