I would like to make a contents page on the fly,
Can i target a h1 tag on say page 001.html & 002.html and display it on contents.html using jquery?
Yes.
$('#result').load('001.html h1');
Where the h1
is a selector that will select your heading.
contents.html
<div id="target"></div>
<script src=//jquery.min.js"></script>
<script type="text/javascript">
$.get('001.html', function(html){
$('#target').text($('h1',html).text());
});
</script>
Where #target
is an element with the id target
within the contents page, and h1
is a selector that locates the <h1>
you're after on the 001.html page.
` is id'd as `header`. (Judging by original question, we can't assume this).
– Brad Christie Feb 28 '13 at 14:12