JavaScript: 'foo.value' not working in IE?
        Posted  
        
            by pete
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by pete
        
        
        
        Published on 2010-04-13T20:41:28Z
        Indexed on 
            2010/04/13
            20:43 UTC
        
        
        Read the original article
        Hit count: 461
        
Hi! A few hours ago, I was instructed how to style a specific textarea with JS. The following piece of code (thanks again, Mario Menger) works like a charm in Firefox but unfortunately nothing happens in Internet Explorer (7 tested only so far).
var foo = document.getElementById('HCB_textarea');
var defaultText = 'Your message here';
foo.value = defaultText;
foo.style.color = '#888';
foo.onfocus = function(){
    foo.style.color = '#000';
    if ( foo.value == defaultText ) {
        foo.value = '';
    }
};
foo.onblur = function(){
    foo.style.color = '#888';
    if ( foo.value == '' ) {
        foo.value = defaultText;
    }
};
I've already tried to replace 'value' by 'innerHTML' (for IE only) but to no effect. Any suggestions? TIA
© Stack Overflow or respective owner