我有字符串需要在加载页面后替换或附加文本。请参阅HTML代码
<table cellpadding=2 cellspacing=0 width='100%' class='ms-informationbar'
style='margin-bottom: 5px;' border=0>
<tr>
<td width=10 valign=center
style='padding: 4px'><img src='/_layouts/images/exclaim.gif' alt='' />
</td>
<td>Items on this list require content approval. Your submission will not
appear in public views until approved by someone with proper rights.
<a href=javascript:HelpWindowKey("ContentApproval")>More information on
content approval.</a>
</td>
</tr>
</table>
<table cellpadding=2 cellspacing=0
width=100% class='ms-informationbar' style='margin-bottom: 5px;' border=0>
</table>
现在 我必须替换文字
Items on this list require content approval. Your submission will not
appear in public views until approved by someone with proper rights.
<a href=javascript:HelpWindowKey("ContentApproval")>More information on
content approval.</a>**
带
Items on this list require content approval. Your submission will not
appear in public views until approved by someone with proper rights.
<a href=javascript:HelpWindowKey("ContentApproval")>More information on
content approval.</a> The editing session will timeout in 40 minutes
我们怎么做这个jQuery?
答案 0 :(得分:1)
你可以这样做:
首先,在TD元素中放置一个类或id,以便您可以更容易地引用它:
<td class="ApprovalNotice">Items on this list require content approval. Your submission will not
appear in public views until approved by someone with proper rights.
<a href=javascript:HelpWindowKey("ContentApproval")>More information on
content approval.</a>
</td>
现在你可以这样做:
origHtml = $('.ApprovalNotice').html();
$('.ApprovalNotice').html(origHtml + yourText);
或者你可以做一些更简单的事情:
<td class="ApprovalNotice">Items on this list require content approval. Your submission will not
appear in public views until approved by someone with proper rights.
<a href=javascript:HelpWindowKey("ContentApproval")>More information on
content approval.</a><span class="timeout" style="display:none;">your text goes here</span> </td>
然后
$('.timeout').show();
答案 1 :(得分:0)
将ID
添加到您要更改的TD
。
<td id="infoText">...</td>
然后你可以改变这样的内容
$('#infoText').html('New Text')
答案 2 :(得分:-1)
$(document).ready(function(){
$(".ms-informationbar tr td").eq(1).html('Items on this list require content approval. Your submission will not
appear in public views until approved by someone with proper rights.
<a href=javascript:HelpWindowKey("ContentApproval")>More information on
content approval.</a> The editing session will timeout in 40 minutes');
});
这将选择在类.ms-informationbar
的元素中的tr中找到的第二个td,并将其内容替换为引号之间的html。