I am trying to make it so that when I enter something in my textarea box my textarea box becomes black and my a div which holds the title for the box also becomes black. but if nothing is entered into the box or something is entered then erased both of these items will remain grey. As you can see I haven’t attempted to address turning the actually textarea box black at all. Thanks
My jQuery
$( '#message_input' )
.click( function () {
var text = $( this ).val;
if(text == 'add additional information here!') {
$('#message_title').css('color','#666');
} else {
$('#message_title').css('color','#000');
}
});
My HTML
<div id="message_title">Message</div>
<textarea name="message" id="message_input" rows="4" cols="21" maxlength="200"
onfocus="if(this.value=='Add additional information here!')
{this.value='';this.style.color='#000';}"
onblur="if(this.value=='') {
this.value='Add additional information about the fruit here!';this.style.color='#999';}"
>Add additional information here!</textarea>
This is a reference to the
valfunction:This is the output of the function
Make sure you use the right one (99% of all cases use the latter).