Method One: Use regular expressions
1) Find all the content contained in the DIV first
2) Then use regular expressions to match the SVG start, the end of the SVG tag
var data=window.$ (". Layout-canvas"). html (); var content=window.$ ("SVG"). html (); var regex =/<svg (s*?) [^>]*>/; var arr = Data.match (regex); data=arr+content+ "</svg>";
Method Two: Using the method of JS
var data=window.$ ("<svg>"). Append (window.$ ("SVG"). Clone ()). HTML ();
Method One: Use regular expressions
1) Find all the content contained in the DIV first
2) Then use regular expressions to match the SVG start, the end of the SVG tag
var data=window.$ (". Layout-canvas"). html (); var content=window.$ ("SVG"). html (); var regex =/<svg (s*?) [^>]*>/; var arr = Data.match (regex); data=arr+content+ "</svg>";
Method Two: Using the method of JS
var data=window.$ ("<svg>"). Append (window.$ ("SVG"). Clone ()). HTML ();