选择一个三列jQuery

选择一个三列jQuery,jquery,asp.net,css,html,Jquery,Asp.net,Css,Html,如何使用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"); </scri

如何使用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> 
//在本部分中,我尝试选择列,但不选择函数
$('GvGrid').slice(1,3).css(“背景色”,“黄色”);
//$(“GvGrid td:nth child(13):gt(1)”).css(“背景色”、“黄色”);
//选择这个
//选择这个
//选择这个

我的页面继承母版页,上面的脚本尝试选择任何PAR列,但当页面加载时,我看不到行中的样式 谢谢你的评论

  • 您正在选择“GvGrid”,这是一个类。你应该使用 “.GvGrid”以选择类
  • 也许jQuery在加载dom之前运行。你应该把衣服包起来
    $(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>
    
    //在本部分中,我尝试选择列,但不选择函数
    $(文档).ready(函数(){
    $('.GvGrid').slice(1,3).css(“背景色”,“黄色”);
    //$(“GvGrid td:nth child(13):gt(1)”).css(“背景色”、“黄色”);
    });
    
    jQuery在呈现的html上的客户端工作。请发布呈现的html文本。您的许多.NET组件呈现自定义html,无法查看问题所在。。。