Is it possible to copy a div from a website to another?

。_饼干妹妹 提交于 2021-02-19 07:44:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!