如何使用jQuery或CSS选择三列,例如:
以下代码:
<script> //In this part I try to select the columns but not functions
$('GvGrid').slice(1, 3).css("backgroundColor", "yellow");
//$("GvGrid td:nth-child(13):gt(1)").css("backgroundColor", "yellow");
</script>
<table id="TblCom" runat="server" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:GridView ID="Gv" runat="server" AutoGenerateColumns="False" ClientIDMode="Static" RowStyle-CssClass="GvGrid" CellPadding="1">
<HeaderStyle CssClass="GvGrid" HorizontalAlign="Center" />
<Columns>
<asp:BoundField DataField="MES_ANIO" HeaderText="MES"></asp:BoundField>
<asp:BoundField DataField="PERIODO" HeaderText="PERIODO"></asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="CVE_USUARIO" HeaderText="USUARIO" DataNavigateUrlFormatString="/Ventas/RepArchivoPersonalAuxiliarEmp.aspx?prospecto={0}" DataTextField="USUARIO"> //Select this
<ControlStyle CssClass="Texto" />
<ControlStyle CssClass="Texto" />
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="" DataNavigateUrlFormatString="/Contraloria/Nomina/RepComisionesDetalle.aspx?FechaI={0:d}&FechaF={1:d}&CveUsuario={2}&CveRol={3}&TipoProducto=ECO&Estatus={4}&Acum={5}&Pagada={6}&CvePlaza={7}&CveTipoQuincena={8}" DataTextField="ECO" DataTextFormatString="{0:###}" HeaderText="ECO"> //Select this
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="" DataNavigateUrlFormatString="/Contraloria/Nomina/RepComisionesDetalle.aspx?FechaI={0:d}&FechaF={1:d}&CveUsuario={2}&CveRol={3}&TipoProducto=A&Estatus={4}&Acum={5}&Pagada={6}&CvePlaza={7}&CveTipoQuincena={8}" DataTextField="A" DataTextFormatString="{0:###}" HeaderText="A">
</asp:HyperLinkField>
<asp:HyperLinkField DataNavigateUrlFields="" DataNavigateUrlFormatString="/Contraloria/Nomina/RepComisionesDetalle.aspx?FechaI={0:d}&FechaF={1:d}&CveUsuario={2}&CveRol={3}&TipoProducto=B1&Estatus={4}&Acum={5}&Pagada={6}&CvePlaza={7}&CveTipoQuincena={8}" DataTextField="B1" DataTextFormatString="{0:###}" HeaderText="B1"> //Select this </asp:HyperLinkField>
</Columns>
</asp:GridView>
<br />
</td>
</tr>
</table>
我的页面继承母版页,上面的脚本试图选择任何一个列但是当页面加载时我看不到行中的样式 谢谢你的意见。
答案 0 :(得分:1)
$(document).ready(function(){})
中的脚本。我会这样做:
<script> //In this part i try to select the columns but not functions
$(document).ready(function () {
$('.GvGrid').slice(1, 3).css("backgroundColor", "yellow");
//$("GvGrid td:nth-child(13):gt(1)").css("backgroundColor", "yellow");
});
</script>