Reputation: 177
I need to grab the page title's on my website and then insert it into the print version of the pages. I have a seperate print.css ofcourse, but is there any way I can grab that title data, maybe as a variable using jQuery, then insert it using CSS, eg. div:before {content:"variable name goes here"} ? Or is there a better approach to this?
Upvotes: 3
Views: 1638
Reputation: 10523
I'd just have a hidden element on your main page that gets a display:block;
in the print CSS.
Upvotes: 1
Reputation: 25165
Sure!
// this would be an example of how to grab the title
<script language="JavaScript">
alert(document.title);
</script>
My approach would be slightly different.
<h1 class="web-hide">the page title goes here</h1>
And then you would have a .web-hide
that would be visible/not-visible depending on the print/not-print version of the page.
Upvotes: 0