jquery获取点击标签内的子标签内容和值实例
今天有点累了,就不多做其他的描述解释。在插入的代码里相关解释也都有。
<!--<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">--> <!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">-->
<!DOCTYPE html>
<html>
<head>
<!-- <base href="<%=basePath%>">--> <!-- <%@ include file="/include/meta.jsp"%>
<title>My JSP 'hello.jsp' starting page</title>-->
<meta charset="UTF-8">
<script src="js/jquery.js"></script>
<!-- <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">
--> </head>
<style type="text/css">
div{
margin-left: 30px;
} table{
border: 1px double #b8d4d1;
/*消除表格之间的间距*/
border-collapse: collapse; } th{
border-top: 1px double #b8d4d1;
border-right: 1px double #b8d4d1;
font-size: 20px;
text-align: center;
/*必须存在最大的宽度否则td里的信息不会缩略显示*/
max-width: 50px;
/*规定段落中的文本不进行换行*/
white-space: nowrap;
/*内容过多的隐藏*/
overflow: hidden;
/*溢出的文字显示为省略号*/
text-overflow: ellipsis;
/*消除表格之间的间距*/
/*border-collapse: collapse;*/
background: linear-gradient(#cafce7,#ffffff);
background:-moz-linear-gradient(top,#cafce7,#ffffff);
background:-webkit-linear-gradient(top,#cafce7,#ffffff);
}
td {
border-top: 1px double #b8d4d1;
border-right: 1px double #b8d4d1;
text-align: center; /*必须存在最大的宽度否则td里的信息不会缩略显示*/
max-width: 50px;
/*规定段落中的文本不进行换行*/
white-space: nowrap;
/*内容过多的隐藏*/
overflow: hidden;
/*溢出的文字显示为省略号*/
text-overflow: ellipsis;
/*消除表格之间的间距*/
/*border-collapse: collapse;*/
/* background: linear-gradient(#cafce7,#ffffff);
background:-moz-linear-gradient(top,#cafce7,#ffffff);
background:-webkit-linear-gradient(top,#cafce7,#ffffff);*/
} #top{
height: 100px;
}
#bottom{
height: 400px;
border: 1px double #b8d4d1;
}
/*鼠标停留在tr标签上时改变颜色*/
tr:hover{
background-color: #e4e8ec; }
</style> <script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
//将点击的tr对象化
$("tr").click(function () {
//在点击事件里使用children()方法和eq(1)方法获取tr下的每个td元素的内容
var username=$(this).children().eq(1).text();
var password=$(this).children().eq(2).text();
//在个input标签赋值
$("#username").val(username);
$("#password").val(password); });
}); </script> <body>
<div id="top">
<form action="myUser/save" method="post">
<input type="hidden" name="id"/>
帐号:<input type="text" id="username" name="username"/><br/>
密码:<input type="text" id="password" name="password"/><br/>
<input type="submit" style="float:none;" value="保存"/>
</form>
</div> <div id="bottom">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th>序号</th>
<th>帐号</th>
<th>密码</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!-- <c:forEach items="${pageInfo.content}" var="MyUser" varStatus="status">
<tr>
<td>
${status.count}
</td>
<td>
${MyUser.username}
</td>
<td>
${MyUser.password}
</td>
<td><a href="myUser/del?id=${MyUser.id}">删除</a></td>
</tr>
</c:forEach>-->
<tr>
<td>主键</td>
<td>帐号</td>
<td>密码</td>
<td>操作</td>
</tr>
<tr>
<td>主</td>
<td>帐号1</td>
<td>密码1</td>
<td>操作</td>
</tr>
</tbody>
</table>
</div>
<!--<tags:pagination page="${pageInfo}" paginationSize="5"/>-->
</body>
</html>
jquery获取点击标签内的子标签内容和值实例的更多相关文章
- 织梦channel标签内调用子栏目内容
文件:include\taglib\channel.lib.php 把代码 SELECT id,typename,typedir,isdefault,ispart,defaultname,nameru ...
- MyBatis配置文件中的标签mappers的子标签mapper的url属性
在浏览器中输入file:/可以打开访达根目录,file:后面至少跟一个杠 MyBatis配置文件中的标签mappers的子标签mapper的url属性中file:后面至少要跟两个杠
- jQuery获取点击对象的父级
一.使用$('body').on('click','.index',function(event){})绑定事件时,例: <div class="project-box"&g ...
- 关于Jquery获取Table中td内的内容
$(this).children().eq(1).text()获取的是显示的值$(this).children().eq(1).html()获取的是<td></td>之间的所有 ...
- jquery怎么获取当前标签下的子标签
1.var num1=$("ul > a:eq(0)").attr("ID");2.var num2=$("ul").children ...
- jquery 获取点击事件的id;jquery如何获取当前触发事件的控件ID值
写html时这样绑定 <input type="text" name="address4" id="address4" onFocus ...
- jquery获取点击控件的绝对位置简单实例
在使用jquery的过程中,想取得当前点击input的绝对位置而去显示一个div,jquery本身提供offset和position这个两个方法,但position官方解释是relative to t ...
- jquery获取li里面的第一个a标签
$("li").children("a:eq(0)") ; children()查找子元素,eq() 查找第几个 $('.active').children(& ...
- jquery获取具有多个类class的标签内容
var tag = $('div.firstClassName.secondClassName.thirdClassName'); 注意空格
随机推荐
- python .py .pyc .pyw .pyo .pyd区别
.py 文件 以 .py 作扩展名的文件是 Python 源代码文件,由 python.exe 解释,可在控制台下运行.当然,也可用文本编辑器进行修改. .pyc 文件 以 .pyc 作扩展名的文件是 ...
- vi编辑器命令大全
>> from zhuhaiqing.info
- spring源码解析之IOC容器(二)------加载和注册
上一篇跟踪了IOC容器对配置文件的定位,现在我们继续跟踪代码,看看IOC容器是怎么加载和注册配置文件中的信息的.开始之前,首先我们先来了解一下IOC容器所使用的数据结构-------BeanDefin ...
- 跟我一起写 Makefile(二)[转]
原文链接 http://bbs.chinaunix.net/thread-408225-1-1.html(出处: http://bbs.chinaunix.net/) 一.Makefile里有什么? ...
- 如何搭建maven项目和搭建ssm框架
1.基本概念 1.1.Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One ...
- cnn 实例
http://www.geekcome.com/content-10-3761-1.html http://www.geekcome.com/content-10-3761-1.html http:/ ...
- 转载:python基础之模块
作者:武沛齐 出处:http://www.cnblogs.com/wupeiqi/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接. 模块,用一 ...
- 【模式识别】CART和GML AdaBoost MATLAB TOOLBOX
GML AdaBoost Matlab Toolbox是一款很优秀的AdaBoost工具箱,内部实现了Real AdaBoost, Gentle AdaBoost和Modest AdaBoost三种方 ...
- hdu 3718 Different Division
Different Division Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- win7旗舰版 安装IIS中出现的问题
最好先安装IIS成功了,再安装VS2010或者别的版本 1.hppt 错误500.19,-Internal server erroe,无法访问的请求野蛮,因为该页的相关配置数据无效,HTTP Erro ...