...

View Full Version : onFocus eventListener for all Textareas



Antoniohawk
07-01-2005, 12:45 AM
Is it possible to add an eventListener of onFocus for every textarea in a page without declaring it for each? For example, let's say that when any textarea is put into focus, all of the text in it is selected.

glenngv
07-01-2005, 03:37 AM
Call this onload.

function setEvent(){
var tas = document.getElementsByTagName('textarea');
var len = tas.length;
for (var i=0; i<len; i++){
tas[i].onfocus = function(){this.select();};
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum