首页 > 代码库 > 搜索框点进原有提示语消失

搜索框点进原有提示语消失

<script language="javascript" type="text/javascript">

function clearText(field)
{
if (field.defaultValue =http://www.mamicode.com/= field.value) field.value = ‘‘;
else if (field.value =http://www.mamicode.com/= ‘‘) field.value = field.defaultValue;
}

</script>

 

<div id="search_box">
<form action="#" method="get">
<input type="text" value="http://www.mamicode.com/Enter a keyword here..." name="q" size="10" id="searchfield" title="searchfield" onfocus="clearText(this)" onblur="clearText(this)" />
<input type="submit" name="Search" value="" id="searchbutton" title="Search" />
</form>
</div>