meta dynamic with javascript / jquery -
i need make dynamic meta. on click or on load page, field of metatags have take content inside tag <h1>. it's possible?
<html> <head> <title>my site</title> <meta property="og:title" content="" /> <meta property="og:description" content="" /> <meta property="og:image" content="" /> </head> <body> <h1 id="titolo">titolo</h1> <p id="descrizione">vestibulum velit justo, porta aliquet a; sodales nec quam. etiam lobortis tortor ex, non iaculis dolor interdum in!</p> <img id="immagine" src="immagine.jpg" /> <a target='_blank' class="fb"href='https://www.facebook.com/sharer/sharer.php?u=http://miosito.org/' >share facebook</a> <a target='_blank' class="tw" href='https://twitter.com/intent/tweet?url=http://miosito.org/ '>share twitter</a> <a target='_blank' class="gplus" href='https://plus.google.com/share?url=http://miosito.org/' >share gplus</a> </body> </html>
thanks
to achieve jquery try this:
$('meta[property=og:title]').attr('content', 'new content');
where 'new content' content wish place inside it.
edit: want , set content what's in h1 might try:
$('meta[property=og:title]').attr('content', $('#titolo').html());
Comments
Post a Comment