Question
What is the complete code to enable jQuery on the page, and then use it to replace the contents of the DIV with HTML text from an external file?
Background
I am new to jQuery, and I really want to work with him to learn this. I have a website where I need to replace the contents of the same div (footer) that exists on every page. Fortunately, each of these pages already imports the same header file. So I'm going to change this header file with some jQuery magic! I had trouble finding complete examples , and I thought that others might have similar questions. Who better to ask than an SO guru?
Example
Given the basic HTML file Example.html :
<html> <head> </head> <body> <div id="selectedTarget"> Existing content. </div> </body> </html>
And the external file includes/contentSnippet.html containing the html fragment:
<p> Hello World! </p>
What will be the new Example.html file that will link the correct jQuery libraries (from the. / Js directory) and replace the contents of the div through jQuery?
javascript jquery jquery-selectors
gMale
source share