问题
is it possible to copy a div from a site to another? Managing many websites I need to copy some static portions of code (e.g. a common footer) without having to go on every website and change it. I was looking to use jQuery, I know about the .clone() but I don't know how to make it work from a site to another
回答1:
I was surfing around looking for an answer and found this code. If you can't use an Iframe.
As an alternative, you could just use a simple and use the jQuery "load" function to load the whole page and pluck out just the section you want:
$('#target-div').load('http://www.mywebsite.com/portfolio.php #portfolio-sports');
There may be other things you need to do, and a significant difference is that the content will become part of the main page instead of being segregated into a separate window.
来源:https://stackoverflow.com/questions/28696294/is-it-possible-to-copy-a-div-from-a-website-to-another