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}
Labels: JavaScript, jQuery, Potongan
7 Comments:
Wah keren gan .. ini bisa" blog ane dari blog DTE lagi .... thanks gan ... apa yang saya cari pasti ada dh disini ... cek www.novaibnu.com
By ibnu, at Monday, June 24, 2013 at 4:19:00 PM GMT+7
Mantab Bos ... Langsung Praktek :)
By Anonymous, at Friday, June 28, 2013 at 5:05:00 PM GMT+7
untuk masalah blog agar lebih ringan (scroll dan loading) kira2 kode mana yg harus ane hilangin atau kurangin ya mas ?? bantuannya dong..
By Fajrin, at Wednesday, July 3, 2013 at 11:13:00 AM GMT+7
mas taufik, caranya mengalihkan hosting css misalkan yang mas lakukan untuk blog ini ke googlecode itu bagaimana ya?
By dhanyn10, at Saturday, July 13, 2013 at 11:42:00 AM GMT+7
⇒ /2013/02/hosting-file-dengan-google-code-dan.html
By Taufik Nurrohman, at Sunday, July 14, 2013 at 6:35:00 PM GMT+7
:D benar2 dukun Jquery, top deh.... ^_^
By Admin, at Monday, July 29, 2013 at 10:41:00 AM GMT+7
bagus tapi kurang tertarik.. soalnya masih kurang fa
By Anonymous, at Saturday, December 7, 2013 at 4:45:00 PM GMT+7
Post a Comment
<< Home