views:

59

answers:

2

Hi! I'm wondering how to add

onblur="hcb.watermark.blur(event)" onfocus="hcb.watermark.focus(event)" style="color: rgb(136, 136, 136);

to the following textarea without having direct access to it:

<textarea rows="4" id="HCB_textarea" name="content" class="commentbox hcb-shadow-r" onkeypress="hcb.delta(event)"/>

Could some additional JS do the job?

A: 

Use jQuery to attach the events, change the style.

Mendy
A: 

You can grab the element using document.getElementById and manipulate it from there.

var textArea = document.getElementById('HCB_textarea');
textArea.onblur = hcb.watermark.blur;
textArea.onfocus = hcb.watermark.focus;
textArea.style.color = 'rgb(136, 136, 136)';
Matt
Thank you! I'll try this...
vince
Is it somehow important where to insert the extra code (before/after the main JS script)?
vince
Works like a charm - thanks, Matt.
vince