2010-11-29 156 views
0

我有下面的html結構,我試圖選擇包含文本'相關列表項'的行。我們的jquery如下: $('#WebPartWPQ3> table(eq:2)> tbody> tr> td> table> tbody> tr:last')。remove(); 但不工作...Jquery父子選擇器

<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> 

回答

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

+1,更有意義。 – karim79 2010-11-29 11:13:05

1

我寧願給一個ID,TR和ID刪除TR。 $('#trid').remove();

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