替换&与&使用jquery

时间:2017-01-11 09:20:53

标签: javascript jquery

<tr>
    <td nowrap="true" valign="top" width="113px" class="ms-formlabel"><h3 class="ms-standardheader"><a name="SPBookmark_Category"></a>Category</h3></td>
    <td valign="top" class="ms-formbody" width="350px" id="SPFieldChoice">
    <td width="350" class="ms-formbody" id="SPFieldChoice" valign="top">
    <!-- FieldName="Category"
         FieldInternalName="Category"
         FieldType="SPFieldChoice"
      -->
        Health &amp; Fitness        
    </td>
</td>
</td>
</tr>

我需要使用&amp;中的jQuery将&替换为Health &amp; Fitness。我怎么能这样做。

3 个答案:

答案 0 :(得分:1)

使用javascript字符串.replace函数。

var el = $('#SPFieldChoice');
el.html(el.html().replace("&amp;", "&"));

答案 1 :(得分:0)

1)你不应该为不同的

拥有相同的IP

2)使用$('idOfYourNode').text().replace("&amp;", "&");

答案 2 :(得分:0)

Working Fiddle

找到td文本并使用替换。

$('td#SPFieldChoice').text().replace('&amp;','&')
相关问题