51代码网ORACLEMYSQLSQL SERVER其它数据库java/jspasp/asp.netC/C++/VC++APP应用其它语言服务器应用
您现在的位置: 51代码网 >> java >> 文章正文

jquery与js隐藏和显示如何实现

更新时间:2012-9-24:  来源:51代码网

<%@ 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="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="/jquery/js/jquery-1.3.1.js"></script>
<script type="text/javascript">
function ckl()
{

}
function ss()
{
$("one").css("display","none");
$("two").css("display","block");
}
function dosth(){

document.getElementById("two").style.display="block";
document.getElementById("one").style.display="none";
}

</script>

  </head>
  
  <body>
  <div id="one">
  <form action="/jquery/login" method="post">
 
  <table align="center" id="tbllogin">
  
  <tr>
  <td>用户名:</td>
  <td><input type="text" name="u.name"/></td>
  </tr>
  <tr>
  <td>密码:</td>
  <td><input type="password" name="u.password"/></td>
  </tr>
  <tr>
  <td><input type="button" value="提交"/></td>
  <td><input type="button" value="注册" id="btnReg" onclick="dosth()" /></td>
  </tr>
  
  </table>
  </form>
  </div>
  <div id="two" style="display:none">
   
  <table align="center" id="tblregist">
  <form action="/jquery/redist" method="post">
  <tr>
  <td>用户名:</td>
  <td><input type="text" name="u.name"/></td>
  </tr>
  <tr>
  <td>密码:</td>
  <td><input type="password" name="u.password"/></td>
  </tr>
  <tr>
  <td colspan="2"><input type="button" value="提交"/></td>
 
  </tr>
 

  </form>
  </table>
  </div>
  </body>
</html>
我用方法dosth()或ss()都实现不了一个现实一个隐藏为什么啊,求解,各位大牛
页面上有没有和one、two一样的id?
function hiden(){
$("#ID").hide();//hide()函数,实现隐藏,括号里还可以带一个时间参数(毫秒)例如hide(500)以500毫秒的速度隐藏,还可以带slow,fast
}
function show(){
$("#ID").show();//显示,参数说明同上
}
这样也行jquery id引用要加 # $("#one").css("display","none");
function ss()
{
$("#one").css("display","none");
$("#two").css("display","block");
}

jquery 根据ID获取元素时,要加一个井号 “#”

  • 上一篇文章:
  • 下一篇文章: 没有了
  • 赞助商链接
    推荐文章
  • 此栏目下没有推荐文章
  • {
    设为首页 | 加入收藏 | 友情链接 | 网站地图 | 联系站长 |