Last active
April 22, 2016 13:26
-
-
Save stnvh/261a91d321842d34a85f to your computer and use it in GitHub Desktop.
left hand assignment ftw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ie placeholders */ | |
$('[placeholder]').on('focus blur', function() { | |
var h = this.getAttribute('placeholder'), v = this.value; | |
this.value = !v && h || ((v != h) && v || ''); | |
}).trigger('blur'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(d) { | |
for(var p = d.querySelectorAll('[placeholder]'), l = 0; l < p.length; l++) { | |
for(var a = (d.attachEvent ? 'attachEvent' : 'addEventListener'), c = ['focusin', 'focusout'], e = 0; e < c.length; e++) { | |
if(a.match(/t$/)) c[e] = 'on' + c[e]; | |
p[l][a](c[e], (function(f) {f = function(o) { | |
var s = (o == this ? o : window.event.srcElement); | |
h = s.getAttribute('placeholder'), v = s.value; | |
s.value = !v && h || ((v != h) && v || ''); | |
} | |
return (e < 1 && f.apply(p[l],[p[l]])) || f; | |
})(), false) | |
} | |
} | |
}(document))() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment