上次同学说写搜索表单号要显示请输入,但是点击输入就点搜索,输入框的值是空的,点击输入框表单号消失,自己试了下

来源:互联网 发布:京东商城和淘宝销售额 编辑:程序博客网 时间:2024/06/06 09:38
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 <%
 String path = request.getContextPath();
 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
     <base href="<%=basePath%>">
     
     <title>My JSP 'index.jsp' starting page</title>
  <meta http-equiv="context-type" content="text/html;charset=utf-8">
  <script type="text/javascript">
  function check(o){
  if(o.value=='') {
  document.getElementById('input_Info').style.display='block';
  }
  }
  </script>
 
   </head>
   
   <body>
   <form action="search" method="post">
  请输入运单号:<input type="text" style="font-size:16px;font-weight:100;"  id="search" name="search" onfocus="document.getElementById('input_Info').style.display='none';" 
   onblur="check(this);" />  <input type="submit">
    <div id="input_Info" style="position:relative;top:-25px;left:115px;font-size:16px;font-weight:100;" onclick="document.getElementById('search').focus();">请输入...</div>
  
   </form>
   </body>

 </html>


 

 显示效果

 

鼠标点击输入框, 请输入消失 。。。。


还有一个是div 在table标签无法隐藏,可以在table里加一个tbody 里面放div 。

原创粉丝点击