要把javascript写在单独的的函数怎么写?
来源:百度知道 编辑:UC知道 时间:2024/05/03 05:00:29
把下面的javascript写在单独的function AA(){},并在<input type="text" name="textfield"/>里调用,谁来写
-------------------------------------------------------------
<input style='color:#ccc' onblur="if(this.value==''){this.value='请输入职位名称快速搜索!';this.style.color='#ccc';}" onfocus="if(this.value=='请输入职位名称快速搜索!'){this.value='';this.style.color='#000000'} "value="请输入职位名称快速搜索!" type="text" name="textfield"/>
-------------------------------------------------------------
<input style='color:#ccc' onblur="if(this.value==''){this.value='请输入职位名称快速搜索!';this.style.color='#ccc';}" onfocus="if(this.value=='请输入职位名称快速搜索!'){this.value='';this.style.color='#000000'} "value="请输入职位名称快速搜索!" type="text" name="textfield"/>
<body>
<input id="search" style='color:#ccc' onblur="getValue();void(0);" onfocus="getValue();void(0);"value="请输入职位名称快速搜索!" type="text" name="textfield"/>
</body>
</html>
<script type="text/javascript">
function getValue()
{
if(document.getElementById("search").value=='')
{
document.getElementById("search").style.color='#ccc'
document.getElementById("search").value='请输入职位名称快速搜索!'
}
else
{
document.getElementById("search").style.color='#000000'
document.getElementById("search").value=''
}
}
</script>
function aa(){
var tbox=document.getElementByName["textfield"];
var id= document.getElementByName["textfield"