I'm having trouble clearing a text field using this function. The alert is working but the field remains unchanged. What could be the issue?
This function is designed to work on any text field.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function clearTextField(target)
{
alert('before...' + target.value);
if ($(target).value == "Search ")
{
$(target).value = "set to something else";
$(target).style.color = '#000000';
$(target).style.fontStyle = 'italic';
}
else
{
$(target).value = "";
}
alert('after...' + target.value);
}
</script>
<title>My page</title>
</head>
<body>
<div class="historysearch">
<input id="username" type="text" value="Search " onclick="clearTextField(this)"/>
</div>
</body>
</html>