用jQuery获取table中行id和td值的实现代码
<%
String path = request.getContextPath();
%>
点击
<Meta content="IE=edge" http-equiv="X-UA-Compatible">
<<a href="/tag/Meta/" target="_blank" class="keywords">Meta</a> http-equiv="pragma" content="no-cache">
<<a href="/tag/Meta/" target="_blank" class="keywords">Meta</a> http-equiv="cache-control" content="no-cache">
<<a href="/tag/Meta/" target="_blank" class="keywords">Meta</a> http-equiv="expires" content="0">
<<a href="/tag/Meta/" target="_blank" class="keywords">Meta</a> http-equiv="keywords" content="keyword1,keyword2,keyword3">
<<a href="/tag/Meta/" target="_blank" class="keywords">Meta</a> http-equiv="description" content="This is my page">
<jsp:include page="/demo/base/js_bootstrap.jsp" />
<script type="text/javascript">
$(function(){
//用jQuery<a href="/tag/huoqu/" target="_blank" class="keywords">获取</a>table中td值
$("#mytable td").click(function(){
alert("table td值:"+$(this).text());
});
//jQuery<a href="/tag/huoqu/" target="_blank" class="keywords">获取</a>table中点击位置所在行的id
$("#mytable td").click(function() {
//td的id
alert($(this).attr("id"));
//tr的id
alert($(this).parent().attr("id"));
});
});
</script>
以上这篇用jQuery获取table中行id和td值的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。