我正在创建一个带有按钮的可共享连接,我之前单击的按钮将执行一项功能,该功能会在发布到社交媒体后修改 OPEN GRAPH。我尝试单击该按钮并使用共享 API 与社交媒体共享它,但标题、链接、缩略图和描述没有改变。
const share = $("#change").click(()=>{
$("meta[name=description]").remove();
$("head").append("<meta name='description' content='new description'>"
);})
您可以使用此更改元标记
$('button').on('click', function() {
$('meta[name=description]').remove();
$('head').append( '<meta name="description" content="this is new">' );
console.log($('meta[name=description]').attr('content'));
});
<head>
<meta name="description"content="this is old">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<button>Change Meta</button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句