Thursday, 19 September 2013

add placeholder jquery to textarea too?

add placeholder jquery to textarea too?

I have this code witch adds IE support for placeholder input types, i
wan`t that it supports also tags with placeholder. Link to the js query
code...
http://placeholder-fixer.googlecode.com/svn/trunk/placeholder_fixer.js
function PlaceholderFixer(){
var tmp_input = document.createElement("input");
this.is_placeholder_supported = "placeholder" in tmp_input;
this.is_onpropertychange_supported = "onpropertychange" in tmp_input;
this.init();
}
PlaceholderFixer.prototype._addEvent = function(element, type, handler){
if (element.addEventListener){
element.addEventListener(type, handler, false);
} else if (element.attachEvent){
element.attachEvent("on" + type, handler);
} else {
element["on" + type] = handler;
}
};
PlaceholderFixer.prototype.init = function(){
var me = this;
var inputs = document.getElementsByTagName("input");
for(var i=0, len=inputs.length; i<len; i++){
var input = inputs[i],
text = input.getAttribute("placeholder");
if(text && !this.is_placeholder_supported){
me._fix(input, text);
}
me._addChangedProperty(input);
}
}; all code is in the given link....

No comments:

Post a Comment