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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -