我有一个这样的div:
<div id="beskrivelse" class="description html_content" itemprop="description">
{{description}}
</div>
内容{{description}}
在后端制作。
我如何才能将此内容显示在我的元数据中:
<meta property="og:description" content=" HERE "/>
如果我写的话,我会收到语法错误:
<meta property="og:description" content=" {{description}} "/>
这是一个简单的方法吗?也许把它放在某种变量中?
当我使用封闭系统时,我无法在后端更改此设置。
我希望我在{{description}}
中写的内容显示在元标记中。
有什么建议吗?
答案 0 :(得分:0)
使用JavaScript可以实现这一目标。
<script language="javascript">
var descval = document.getElementById('beskrivelse').innerHTML;
var paras = document.getElementsByTagName('meta');
for (i = 0; i < paras.length; i++) {
var test = paras[i].getAttribute('property');
if(test == "og:description")
{
paras[i].content = descval;
}
}
</script>
使用开发人员工具,您可以检查元标记的新内容。