【问题标题】:Using jQuery to add one tag into another tag使用 jQuery 将一个标签添加到另一个标签中
【发布时间】:2013-03-12 19:24:54
【问题描述】:

遇到了一个难题,希望各位好心人能帮我解决...

目标:

使用 jQuery,我正在尝试添加所有出现的:

<pre> ... </pre>

与:

<pre><code> ... </code></pre>

【问题讨论】:

    标签: jquery html tags


    【解决方案1】:
    $('pre').wrapInner('<code>');
    

    参考:wrapInner

    jsFiddle example

    【讨论】:

      【解决方案2】:
      $('pre').html('<code>'+$('pre').html()+'</code>');
      

      【讨论】:

        【解决方案3】:

        使用 .wrapInner()

        $("pre").wrapInner("<code></code>");
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-10-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多