我正在尝试找到解决方法,从SharePoint 2007网站上的“通知摘要视图”中删除“依据”行。出于各种原因,我在网上找不到的任何东西似乎都在起作用 - 所以我想采取另一种方式,只要一些才华横溢的灵魂会有所帮助。有谁知道如何使jQuery工作有些神奇,所以HTML的第一个块最终可以作为第二个HTML块呈现?
第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"> </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@address.com" id="imn0,type=smtp" ></a></span></nobr></td><td width=20% align="right" nowrap class="ms-vb"> 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座:
<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"> </span></td><td width=20% align="right" nowrap class="ms-vb"> 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>
这是我需要删除的内容:
<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@address.com" id="imn0,type=smtp" ></a></span></nobr>
----------------------------更新更好的格式化--------------- ---------------- 我真的没有看到jQuery可以选择的东西。此外,这来自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"> </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@address.com" id="imn0,type=smtp" ></a></span>
</nobr>
</td>
<td width=20% align="right" nowrap class="ms-vb"> 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> </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"> </span>
</td>
<td width=20% align="right" nowrap class="ms-vb"> 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> </font>
</TD>
</TR>
答案 0 :(得分:0)
您可以执行此操作以删除它,虽然它可能有助于了解包装它的内容,因此您不会意外删除需要保留的内容。在我的例子中,我刚刚在罪魁祸首周围放置了一个div:
演示:http://jsfiddle.net/lucuma/yyEXU/1/
代码:
$('div').html($('div').html().replace('by',''))
或者你可以使用正文或文档来更普遍:
$('body').html($('body').html().replace('by',''));
由于td's
包含by,您可以对此进行优化,然后查找单词by
,并根据需要仅对其进行替换:
$('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.
}
答案 1 :(得分:0)
使用此:
$('.ms-partline').parent().parent().parent().remove();
它只会删除sharepoint中的视图