【问题标题】:How to replace html tags with new line character in jquery + imagemagick?如何在jquery + imagemagick中用换行符替换html标签?
【发布时间】:2013-03-17 13:30:42
【问题描述】:

我有一个内容可编辑的 div。所以照了一个很好的post here 在不同浏览器的输入键上添加 html 标签。现在我想用一个新的线条字符替换这些并将其发送到 imagemagick 插件以创建一个新的线条效果。 我如何在客户端使用 jquery 来做到这一点。

我正在尝试这样做但没有得到结果:

messageText1 = $("#templateIframe")
  .contents()
  .find("#dialog")
  .html()
  .replace(/<(?:.|)*?>/gm, '\\n')
  .replace(/&nbsp;/g, '');

alert(messageText1);
messageText = messageText1.replace(/\n{2}/g, '\\n');
alert(messageText1);

【问题讨论】:

    标签: jquery contenteditable


    【解决方案1】:

    post得到解决方案

    messageText = $("#templateIframe")
    .contents()
    .find("#dialog")
    .html()
    .replace(/<(?:.|)*?>/gm, '\\n')
    .replace(/&nbsp;/g, '')
    .replace(/\\n\\n/g,"\\n");
    
    alert(messageText);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-23
      • 1970-01-01
      • 2013-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-12
      相关资源
      最近更新 更多