Jquery 父子选择器

发布于 2024-10-04 22:45:46 字数 5727 浏览 2 评论 0原文

我有下面的 html 结构,我试图选择包含文本“相关列表项:”的行。

我的 Jquery 如下: $('#WebPartWPQ3 > table(eq:2) > tbody > tr > td > table > tbody > tr:last').remove(); 但不工作...

 <DIV id="WebPartWPQ3" fixed_bound allowDelete="false" OnlyForMePart="true" HasPers="true" WebPartID="00000000-0000-0000-0000-000000000000" width="100%">
  <TABLE cellSpacing="0" cellPadding="4" width="100%" border="0" fixed_bound xmlns:ddwrt2="urn:frontpage:internal" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <TBODY fixed_bound>
      <TR fixed_bound>
        <TD class="ms-vb" fixed_bound>&nbsp;
        </TD>
      </TR>
    </TBODY>
  </TABLE>
  <TABLE width="100%" border="0" fixed_bound xmlns:ddwrt2="urn:frontpage:internal" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <TBODY fixed_bound>
      <TR fixed_bound>
        <TD fixed_bound>
          <TABLE cellSpacing="0" width="100%" border="0" fixed_bound>
            <TBODY fixed_bound>
              <TR fixed_bound>
                <TD class="ms-formlabel" vAlign="top" noWrap width="25%" fixed_bound>
                  <B fixed_bound>Title:
                  </B>
                </TD>
                <TD class="ms-formbody" vAlign="top" width="75%" fixed_bound>Employee annual leave approval
                  <BR fixed_bound/>
                  <BR fixed_bound/>
                </TD>
              </TR>
              <TR fixed_bound>
                <TD class="ms-formlabel" width="25%" fixed_bound>
                  <B fixed_bound>Approved Carry Forward days
                    <SPAN class="ms-formvalidation" fixed_bound> *
                    </SPAN>:
                  </B>
                </TD>
                <TD class="ms-formbody" width="75%" fixed_bound>
                  <SPAN fixed_bound>
                    <INPUT class="ms-input" id="ctl00_PlaceHolderMain_TaskForm_ff1_1_ctl00_ctl00_TextField" title="Approved Carry Forward days" style="IME-MODE: inactive" size="11" name="ctl00$PlaceHolderMain$TaskForm$ff1_1$ctl00$ctl00$TextField" fixed_bound value=""/>
                    <BR fixed_bound/>
                  </SPAN>
                </TD>
              </TR>
              <TR fixed_bound>
                <TD class="ms-formlabel" width="25%" fixed_bound>
                  <B fixed_bound>Review Comments:
                  </B>
                </TD>
                <TD class="ms-formbody" width="75%" fixed_bound>
                  <SPAN fixed_bound>
                    <TEXTAREA class="ms-long" id="ctl00_PlaceHolderMain_TaskForm_ff2_1_ctl00_ctl00_TextField" title="Review Comments" name="ctl00$PlaceHolderMain$TaskForm$ff2_1$ctl00$ctl00$TextField" rows="5" fixed_bound>
                    </TEXTAREA>
                    <BR fixed_bound/>
                  </SPAN>
                </TD>
              </TR>
              <TR fixed_bound>
                <TD class="ms-formlabel" vAlign="top" noWrap width="25%" fixed_bound>
                  <B fixed_bound>Related list item:
                  </B>
                </TD>
                <TD class="ms-formbody" vAlign="top" width="75%" fixed_bound>
                  <A href="http://orange.extra.net/people/hr/Workflows/Expire%20the%20employee%20year%20in%20a%20year/" fixed_bound>
                  </A>
                </TD>
              </TR>
            </TBODY>
          </TABLE>
        </TD>
      </TR>
    </TBODY>
  </TABLE>
  <TABLE cellSpacing="0" cellPadding="4" width="100%" border="0" fixed_bound xmlns:ddwrt2="urn:frontpage:internal" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <TBODY fixed_bound>
      <TR fixed_bound>
        <TD class="ms-vb" noWrap fixed_bound>
          <INPUT style="DISPLAY: none" onclick="javascript: __doPostBack('ctl00$PlaceHolderMain$TaskForm','__update;__commit;__redirectsource;__redirectToList={};')" type="button" name="btnSave" fixed_bound jQuery1291028280448="3" value="Save Draft"/>
        </TD>
        <TD fixed_bound>
          <INPUT onclick="javascript: __doPostBack('ctl00$PlaceHolderMain$TaskForm','__update;__workflowTaskComplete={0*};__commit;__redirectsource;__redirectToList={};')" type="button" name="btnMarkSubmited" fixed_bound value="Complete Task"/>
        </TD>
        <TD class="ms-vb" noWrap width="99%" fixed_bound>
          <INPUT onclick="javascript: __doPostBack('ctl00$PlaceHolderMain$TaskForm','__cancel;__redirectsource;__redirectToList={};')" type="button" name="btnCancel" fixed_bound value="Cancel"/>
        </TD>
      </TR>
    </TBODY>
  </TABLE>
</DIV>

I have the html structure below and I'm trying to select the row containing the text 'Related list item:'.

My Jquery is below:
$('#WebPartWPQ3 > table(eq:2) > tbody > tr > td > table > tbody > tr:last').remove();
but not working...

 <DIV id="WebPartWPQ3" fixed_bound allowDelete="false" OnlyForMePart="true" HasPers="true" WebPartID="00000000-0000-0000-0000-000000000000" width="100%">
  <TABLE cellSpacing="0" cellPadding="4" width="100%" border="0" fixed_bound xmlns:ddwrt2="urn:frontpage:internal" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <TBODY fixed_bound>
      <TR fixed_bound>
        <TD class="ms-vb" fixed_bound> 
        </TD>
      </TR>
    </TBODY>
  </TABLE>
  <TABLE width="100%" border="0" fixed_bound xmlns:ddwrt2="urn:frontpage:internal" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <TBODY fixed_bound>
      <TR fixed_bound>
        <TD fixed_bound>
          <TABLE cellSpacing="0" width="100%" border="0" fixed_bound>
            <TBODY fixed_bound>
              <TR fixed_bound>
                <TD class="ms-formlabel" vAlign="top" noWrap width="25%" fixed_bound>
                  <B fixed_bound>Title:
                  </B>
                </TD>
                <TD class="ms-formbody" vAlign="top" width="75%" fixed_bound>Employee annual leave approval
                  <BR fixed_bound/>
                  <BR fixed_bound/>
                </TD>
              </TR>
              <TR fixed_bound>
                <TD class="ms-formlabel" width="25%" fixed_bound>
                  <B fixed_bound>Approved Carry Forward days
                    <SPAN class="ms-formvalidation" fixed_bound> *
                    </SPAN>:
                  </B>
                </TD>
                <TD class="ms-formbody" width="75%" fixed_bound>
                  <SPAN fixed_bound>
                    <INPUT class="ms-input" id="ctl00_PlaceHolderMain_TaskForm_ff1_1_ctl00_ctl00_TextField" title="Approved Carry Forward days" style="IME-MODE: inactive" size="11" name="ctl00$PlaceHolderMain$TaskForm$ff1_1$ctl00$ctl00$TextField" fixed_bound value=""/>
                    <BR fixed_bound/>
                  </SPAN>
                </TD>
              </TR>
              <TR fixed_bound>
                <TD class="ms-formlabel" width="25%" fixed_bound>
                  <B fixed_bound>Review Comments:
                  </B>
                </TD>
                <TD class="ms-formbody" width="75%" fixed_bound>
                  <SPAN fixed_bound>
                    <TEXTAREA class="ms-long" id="ctl00_PlaceHolderMain_TaskForm_ff2_1_ctl00_ctl00_TextField" title="Review Comments" name="ctl00$PlaceHolderMain$TaskForm$ff2_1$ctl00$ctl00$TextField" rows="5" fixed_bound>
                    </TEXTAREA>
                    <BR fixed_bound/>
                  </SPAN>
                </TD>
              </TR>
              <TR fixed_bound>
                <TD class="ms-formlabel" vAlign="top" noWrap width="25%" fixed_bound>
                  <B fixed_bound>Related list item:
                  </B>
                </TD>
                <TD class="ms-formbody" vAlign="top" width="75%" fixed_bound>
                  <A href="http://orange.extra.net/people/hr/Workflows/Expire%20the%20employee%20year%20in%20a%20year/" fixed_bound>
                  </A>
                </TD>
              </TR>
            </TBODY>
          </TABLE>
        </TD>
      </TR>
    </TBODY>
  </TABLE>
  <TABLE cellSpacing="0" cellPadding="4" width="100%" border="0" fixed_bound xmlns:ddwrt2="urn:frontpage:internal" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <TBODY fixed_bound>
      <TR fixed_bound>
        <TD class="ms-vb" noWrap fixed_bound>
          <INPUT style="DISPLAY: none" onclick="javascript: __doPostBack('ctl00$PlaceHolderMain$TaskForm','__update;__commit;__redirectsource;__redirectToList={};')" type="button" name="btnSave" fixed_bound jQuery1291028280448="3" value="Save Draft"/>
        </TD>
        <TD fixed_bound>
          <INPUT onclick="javascript: __doPostBack('ctl00$PlaceHolderMain$TaskForm','__update;__workflowTaskComplete={0*};__commit;__redirectsource;__redirectToList={};')" type="button" name="btnMarkSubmited" fixed_bound value="Complete Task"/>
        </TD>
        <TD class="ms-vb" noWrap width="99%" fixed_bound>
          <INPUT onclick="javascript: __doPostBack('ctl00$PlaceHolderMain$TaskForm','__cancel;__redirectsource;__redirectToList={};')" type="button" name="btnCancel" fixed_bound value="Cancel"/>
        </TD>
      </TR>
    </TBODY>
  </TABLE>
</DIV>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小女人ら 2024-10-11 22:45:46
$('.ms-formlabel').last().children().remove();
$('.ms-formlabel').last().children().remove();
平生欢 2024-10-11 22:45:46

我更喜欢给tr一个id,然后通过id删除tr。
$('#trid').remove();

I prefer to give an id to the tr and remove the tr by id.
$('#trid').remove();

等待圉鍢 2024-10-11 22:45:46
$('#WebPartWPQ3').find('Related list item').closest('tr').remove();
$('#WebPartWPQ3').find('Related list item').closest('tr').remove();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文