资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
javascript写的一个表单动态输入提示的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> <style type="text/css"> *{ margin:0px;padding:0px;font-size:12px; } input{ width:100px;height:20px;border:1px solid #ccc; } </style> </head> <body> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20language%3D%22javascript%22%3E%20%0D%0Afunction%20tips(id%2Cstr)%7B%20%0D%0Avar%20l%3Ddocument.getElementById(id).offsetLeft%2B120%3B%20%0D%0Avar%20t%3Ddocument.getElementById(id).offsetTop%3B%20%0D%0Adocument.getElementById(%22tips%22).innerHTML%3D%22%E6%8F%90%E7%A4%BA%EF%BC%9A%22%2Bstr%3B%20%0D%0Adocument.getElementById(%22tips%22).style.left%3Dl%2B%22px%22%3B%20%0D%0Adocument.getElementById(%22tips%22).style.top%3Dt%2B%22px%22%3B%20%0D%0Adocument.getElementById(%22tips%22).style.display%3D%22%22%3B%20%0D%0A%7D%20%0D%0Afunction%20outtips()%7B%20%0D%0A%20%20%20%20document.getElementById(%22tips%22).style.display%3D'none'%3B%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E"> <div id="tips" style="position:absolute;border:1px solid #ccc;padding:0px 3px;color:#f00;display:none;height:20px;line-height:20px;background:#fcfcfc"></div> 姓名:<input type="text" id="username" onfocus="tips('username','姓名长度最多16个字符')" onblur="outtips()" /> 密码:<input type="password" id="password" onfocus="tips('password','密码长度必须在3-18位之间')" onblur="outtips()" /> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
比较简单,自己闲着无聊写的,很久没有写过代码了。。。。
教程首页
更多教程