【问题标题】:jquery replace the content of a #div with the contents of another #div?jquery用另一个#div的内容替换#div的内容?
【发布时间】:2012-07-17 11:32:32
【问题描述】:

如何正确地将 div 的内容替换为另一个 div 的内容?

  • div1
  • div2

我希望 div2 的内容替换 div1 的内容

  $('#start').load('#start_hidden');

【问题讨论】:

    标签: jquery html replace


    【解决方案1】:
    $('#div2').html($('#div1').html());
    

    【讨论】:

      【解决方案2】:

      工作演示 http://jsfiddle.net/M4v4M/

      API:.replaceWithhttp://api.jquery.com/replaceWith/

      希望它符合您的需求:)

      代码

      $('#div2').replaceWith($('#div1').html());​
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-20
        • 1970-01-01
        • 2021-09-15
        • 1970-01-01
        相关资源
        最近更新 更多