jquery用另一个#div的内容替换#div的内容?

Rub*_*tic 2 html jquery replace

我怎样才能正确地用另一个div的内容替换div的内容?

  • DIV1
  • DIV2

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

  $('#start').load('#start_hidden');
Run Code Online (Sandbox Code Playgroud)

小智 8

$('#div2').html($('#div1').html());
Run Code Online (Sandbox Code Playgroud)


Tat*_*nit 5

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

\n\n

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

\n\n

希望它适合您的需求:)

\n\n

代码

\n\n
$(\'#div2\').replaceWith($(\'#div1\').html());\xe2\x80\x8b\n
Run Code Online (Sandbox Code Playgroud)\n