当我处于 td 级别时,如何从 xsl html 表行中提取数据

How can I extract data from an xsl html table row when I am at the td level?

本文关键字:html xsl 数据 提取 td      更新时间:2023-09-26

我在xsl工作表中有一个表,我正在使用ajax来调用它。 用户需要单击数据网格上的字段 (td),然后运行单击事件。 在该单击事件中,我需要提取该行中其他字段的数据。

下面,我的逻辑有alert($(this).parents("tr").attr("id","c3").value());。 为什么这会拉取该行的所有数据,我怎么只能拉取 c3 字段?

	$("#List td").click(function(){
	//alert($(this).parents("tr").html());
	alert($(this).parents("tr").attr("id","wc").value());
	)};
    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java"
	exclude-result-prefixes="java">
	<xsl:output method="html" media-type="text/html" encoding="UTF-8" />
	<xsl:param name="HeaderText"/>
	<xsl:param name="FooterText"/>
	<xsl:template match="/">
	<table id="List">
		<thead>
				<tr>
					<th> DATE_TIME</th>
					<th> COL2</th>
					<th> COL3</th>
					<th> COL4</th>
					<th> COL5</th>
					<th> COL6</th>
					<th> COL7</th>
				</tr>
		</thead>
		<tbody>
			   <xsl:for-each select="/Rowsets/Rowset/Row">
			   <tr>
			   	   <xsl:attribute name="column-two"> <xsl:value-of select="COLUMN_TWO"/> </xsl:attribute>
				   <xsl:attribute name="column-three"> <xsl:value-of select="COLUMN_THREE"/> </xsl:attribute>
				   <xsl:attribute name="column-five"> <xsl:value-of select="COLUMN_FIVE"/> </xsl:attribute> 
				   <td align="center"> <xsl:value-of select="java:...ext.ExtFunctions.dateFromXMLFormat(DATE_TIME,$DateFormat)"/></td>
				   <td id="c2" align="center"> <xsl:value-of select="COLUMN_TWO"/> </td>
				   <td id="c3" align="center"> <xsl:value-of select="COLUMN_THREE" /> </td>
				   <td id="c4" align="center"> <xsl:value-of select="COLUMN_FOUR"/> </td>
				   <td id="c5" align="center"> <xsl:value-of select="COLUMN_FIVE"/> </td>
				   <td id="c6" align="center"> <xsl:value-of select="COLUMN_SIX"/></td>
				   <td id="c7" align="center"> <xsl:value-of select="COLUMN_SEVEN"/></td>
			</tr>
			</xsl:for-each>
		</tbody>
	</table>
<script>
</script>
</xsl:template>
</xsl:stylesheet>

我认为

$("#List td").click(function(){
    alert($(this).parents("tr").attr("id","wc").value());    
)};

应改为

$("#List td").click(function(){
    alert($(this).parents("tr").attr("id","c3").value());    
)};