Search code examples
jquerystaticcopyclonecommon-code

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


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


Solution

  • 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.