【问题标题】:replace & with & using jquery [duplicate]用 & 替换 & 使用 jquery [重复]
【发布时间】:2017-05-26 00:11:56
【问题描述】:
<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>

我需要使用来自Health &amp;amp; Fitness 的jQuery 将&amp;amp; 替换为&amp;。我该怎么做。

【问题讨论】:

  • 检查jsfiddle.net
  • 为什么?它们呈现相同的
  • console.log($("&lt;textarea/&gt;").html('&amp;amp;').text());这是你需要的吗?

标签: javascript jquery


【解决方案1】:

1) 你不应该有不同的IP

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

【讨论】:

    【解决方案2】:

    使用javascript字符串.replace函数。

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

    【讨论】:

      【解决方案3】:

      Working Fiddle

      查找 td 文本并使用替换。

      $('td#SPFieldChoice').text().replace('&amp;','&')
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-28
        相关资源
        最近更新 更多