Jquery父子选择器

时间:2010-11-29 11:04:04

标签: jquery-selectors

我有下面的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>

3 个答案:

答案 0 :(得分:1)

$('.ms-formlabel').last().children().remove();

答案 1 :(得分:1)

我更喜欢给tr一个id并删除id by id。 $('#trid').remove();

答案 2 :(得分:0)

$('#WebPartWPQ3').find('Related list item').closest('tr').remove();