Changing the value of OG:IMAGE with jQuery click

前端 未结 3 1381
长情又很酷
长情又很酷 2020-12-07 02:32

I just build up a image portfolio with a single HTML page where all the pictures are dynamically loaded. Everything works great so far, except for the facebook META OG:IMAGE

3条回答
  •  既然无缘
    2020-12-07 02:54

    It's the colon. Try using single quote & double-quotes like this:

    var imgSrc = $(this).find('img').attr('src'); // image stored as variable
    $('meta[property="og:image"]').attr('content', imgSrc); // assigns meta property
    

提交回复
热议问题