2013-04-15 2 views
-1

SharePoint 2007 사이트의 공지 요약보기에서 "by"줄을 제거하는 방법을 찾으려고합니다. 여러 가지 이유로 웹에서 찾은 어떤 것도 작동하지 않는 것 같습니다. 재능있는 친절한 사람이 도움이된다면 다른 길을 가고 싶습니다. 누구든지 jQuery가 마술을 작동하도록 만드는 방법을 알고 있으므로 HTML의 첫 번째 블록이 HTML의 두 번째 블록으로 렌더링 될 수 있습니다.jQuery가이 텍스트를 삭제할 수 있습니까?

블록 1 :

<a onfocus="OnLink(this)" href="/Lists/Our%20Announcements/DispForm.aspx?ID=36" ONCLICK="GoToLink(this);return false;" target="_self">Title of Annoucement </a><IMG SRC="/_layouts/1033/images/new.gif" alt="New">&nbsp;</span><br>by <nobr><span><A ONCLICK="GoToLink(this);return false;" HREF="/_layouts/userdisp.aspx?ID=2258">Lastname, FirstName I.</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif" alt="" /><a href="javascript:" onclick="IMNImageOnClick();return false;" class="ms-imnlink"><img title="" alt="No presence information" name="imnmark" border="0" valign="middle" height="12" width="12" src="/_layouts/images/blank.gif" sip="[email protected]" id="imn0,type=smtp" ></a></span></nobr></td><td width=20% align="right" nowrap class="ms-vb">&nbsp;4/15/2013 12:51 PM</td></tr><tr><td colspan=2 class="ms-vb"> <div id="{291345DC-BEAE-47B6-8F53-41C07838090C}36"><div class=ExternalClass5BF6EE28A88D436CAC2FE553E7F2CED7><div> 

블록 2 : ----------

<br>by <nobr><span><A ONCLICK="GoToLink(this);return false;" HREF="/_layouts/userdisp.aspx?ID=2258">Lastname, FirstName I.</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif" alt="" /><a href="javascript:" onclick="IMNImageOnClick();return false;" class="ms-imnlink"><img title="" alt="No presence information" name="imnmark" border="0" valign="middle" height="12" width="12" src="/_layouts/images/blank.gif" sip="[email protected]" id="imn0,type=smtp" ></a></span></nobr> 

:

<a onfocus="OnLink(this)" href="/Lists/Our%20Announcements/DispForm.aspx?ID=36" ONCLICK="GoToLink(this);return false;" target="_self">Title of Annoucement </a><IMG SRC="/_layouts/1033/images/new.gif" alt="New">&nbsp;</span></td><td width=20% align="right" nowrap class="ms-vb">&nbsp;4/15/2013 12:51 PM</td></tr><tr><td colspan=2 class="ms-vb"> <div id="{291345DC-BEAE-47B6-8F53-41C07838090C}36"><div class=ExternalClass5BF6EE28A88D436CAC2FE553E7F2CED7><div> 

이것은 내가 제거한해야 할 것입니다 ------------------ 더 나은 형식을위한 업데이트 ---------------------------- --- jQuery ca에 대해 실제로 볼 수있는 것은 없습니다. n을 선택하십시오. 또한 SharePoint에서 가져 오므로 ID 또는 div를 생성 된 코드에 추가 할 수 없습니다.

블록 1 :

<TR> 
     <TD width=80% class="ms-vb" style="padding-bottom: 3px"> 
     <span class="ms-announcementtitle"><a onfocus="OnLink(this)" href="/Lists/Our%20Announcements/DispForm.aspx?ID=36" ONCLICK="GoToLink(this);return false;" target="_self">Title of Annoucement </a><IMG SRC="/_layouts/1033/images/new.gif" alt="New">&nbsp;</span> 
     <br>by 
     <nobr> 
      <span><A ONCLICK="GoToLink(this);return false;" HREF="/_layouts/userdisp.aspx?ID=2258">Lastname, FirstName I.</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif" alt="" /><a href="javascript:" onclick="IMNImageOnClick();return false;" class="ms-imnlink"><img title="" alt="No presence information" name="imnmark" border="0" valign="middle" height="12" width="12" src="/_layouts/images/blank.gif" sip="[email protected]" id="imn0,type=smtp" ></a></span> 
     </nobr> 
     </td> 
     <td width=20% align="right" nowrap class="ms-vb">&nbsp;4/15/2013 12:51 PM</td> 
    </tr> 
    <tr> 
     <td colspan=2 class="ms-vb"> 
      <div id="{291345DC-BEAE-47B6-8F53-41C07838090C}36"> 
      <div class=ExternalClass5BF6EE28A88D436CAC2FE553E7F2CED7> 
      <div> 
      <div> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <b> 
         <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt"> 
          <em>A message from Firstname Lastname</em> 
         </span> 
        </b> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt"></span> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt">Here is the message </span> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt"></span> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt">To... 
      </div> 
     </TD> 
    </TR> 
    <TR> 
     <TD> 
      <font size=1>&nbsp;</font> 
     </TD> 
    </TR> 

블록 2 :

당신은 그렇게 실수로 뭔가를 제거하지 않는 포장되어 무엇인지 알고 도움이 될 수 있지만이 그것을 제거 할 수
 <TR> 
     <TD width=80% class="ms-vb" style="padding-bottom: 3px"> 
     <span class="ms-announcementtitle"><a onfocus="OnLink(this)" href="/Lists/Our%20Announcements/DispForm.aspx?ID=36" ONCLICK="GoToLink(this);return false;" target="_self">Title of Annoucement </a><IMG SRC="/_layouts/1033/images/new.gif" alt="New">&nbsp;</span> 
     </td> 
     <td width=20% align="right" nowrap class="ms-vb">&nbsp;4/15/2013 12:51 PM</td> 
    </tr> 
    <tr> 
     <td colspan=2 class="ms-vb"> 
      <div id="{291345DC-BEAE-47B6-8F53-41C07838090C}36"> 
      <div class=ExternalClass5BF6EE28A88D436CAC2FE553E7F2CED7> 
      <div> 
      <div> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <b> 
         <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt"> 
          <em>A message from Firstname Lastname</em> 
         </span> 
        </b> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt"></span> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt">Here is the message </span> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt"></span> 
       </p> 
       <p style="line-height:normal;margin:0in 0in 0pt;vertical-align:top" class=MsoNormal> 
        <span style="font-family:'Arial','sans-serif';color:black;font-size:9pt">To... 
      </div> 
     </TD> 
    </TR> 
    <TR> 
     <TD> 
      <font size=1>&nbsp;</font> 
     </TD> 
    </TR> 
+0

SharePoint의 도면이다 것들을 삭제됩니다! –

+0

타겟팅 할 올바른 요소를 식별 할 수있는 클래스 나 ID가있는 주변 요소가 있습니까? – jfriend00

+0

답변을 업데이트했습니다. 이 경우'by '라는 단어가 항상'td'안에 있다면 그 단어로'td's '를 검색하고 그 단어를 바꾸거나 원하는 경우 전체 본문을 대체 할 수 있습니다. 네 사건에 달렸어. – lucuma

답변

0

그게 남아 있어야합니다. 내 예에서 그냥 범인 주위 사업부를 배치했습니다

데모 : http://jsfiddle.net/lucuma/yyEXU/1/

코드 :

$('div').html($('div').html().replace('by','')) 

또는 당신은 더 보편적으로 신체 또는 문서를 사용할 수 있습니다

$('body').html($('body').html().replace('by','')); 

td's이 포함되어 있기 때문에 이것을 최적화하고 by이라는 단어를 찾아 보았을 때 해당 단어 만 바꾸면됩니다. NT :

$('td').each(function() { 
    if ($(this).text().indexOf('by')>-1) 
    $(this).html($(this).html().replace('by','')); 
    $('nobr', this).remove(); // if the nobr contains by we remove this. 
    // $(this).empty() // this will remove the contents and keep the tags. 
} 
+0

귀하의 솔루션이 사람 이름도 삭제합니까? 나는''태그들 사이에있는 모든 것을 제거해야한다. – Mark

+0

죄송합니다. 오해했습니다. nobr 태그도 제거 하시겠습니까? 태그를 제거하거나 내용을 제거하는 코드를 추가합니다. – lucuma

+0

예, 전체 줄 전체에 "이것은 내가 제거해야하는 것입니다 :"라고 표시되어 있습니다 (어떤 의미로도 의미가 없습니다). 그런데 고맙습니다. – Mark

0

사용이 :

$('.ms-partline').parent().parent().parent().remove(); 

그것은 단지 그것을 볼 쉽다 있도록 코드를 포맷해야

관련 문제