Home » , , » Cross Browser HTML5 Placeholder

Cross Browser HTML5 Placeholder

JQuery

$('[placeholder]').each(function() {
var plc = $(this).attr('placeholder');
$(this).addClass('blur').removeAttr('placeholder').val(plc).on("focus blur", function(e) {
// Add a `blur` class to fade the text color for the default placeholder text
$(this)[(e.type == "blur" && (this.value === "" || this.value == plc)) ? "addClass" : "removeClass"]('blur');
// Set the value to `plc` on blur if the element value is empty
if (e.type == "blur" && this.value === "") $(this).val(plc);
// Set the value to empty on focus if the element value is same with the default placeholder text
if (e.type == "focus" && this.value == plc) $(this).val("");
});
});

CSS

input.blur,
textarea.blur {color:#bbb}
Jika Anda menyukai Artikel di blog ini, Silahkan klik disini untuk berlangganan gratis via email, dengan begitu Anda akan mendapat kiriman artikel setiap ada artikel yang terbit di Creating Website

0 comments:

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Homtimpa - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger