Possible Duplicate:
Find html label associated with a given input
I have following html code -
<label for='useremail'>Registered email address</label>
<input type='text' value='' name='useremail' onfocus='hideLabel("useremail");' id='useremail' class='useremail'>
in my webpage and below code in Javascript
function hideLabel (fieldname) {
document.getElementById(fieldname).label.style.visibility = 'hidden'; }
My intent is to hide label when user clicks on the input field. When I am testing this, I am getting following error. Is something wrong with my code?
Unhandled Error: Cannot convert 'document.getElementById(fieldname).label' to object