javascript - Wemassembly 设置元标记
问题描述
我正在尝试设置元标记。
<meta name="description" content="text here"/>
这是我尝试过的,但它不起作用,也不会导致任何错误。
js.Global().Get("document").Set(`meta[name="description"]`, "new text here")
有什么建议么?
解决方案
我认为您当前所做的与document["meta[name=\"description\"]"] = "new text here"
JavaScript 中的相同,它并没有做您想要的。
您需要的可能是这样的:
document.querySelector(`meta[name="description"]`).content = "new text here"
您可以使用Call
实际选择您的元素querySelector
,然后content
像这样设置它的属性:
js.Global().Get("document").Call("querySelector", `meta[name="description"]`).Set("content", "new text here")
推荐阅读
- r - 如何用最接近的两个值的平均值替换 NA
- c# - 使用 FluentFTP 通过 TLS/SSL 向/从 FTP 服务器传输时,“身份验证失败,因为远程方已关闭传输流”
- python - 为什么当我们为列表列表中的每个列表列出列表的所有元素时,我们需要在 for in 子句中使用特定的顺序?
- kubernetes - 意外覆盖了默认的集群管理员角色
- jsf - 浏览器不解释 JSF 标记
- java - 在这种情况下,如何根据单击的单选按钮检索数值?
- python - Python ortools 安排每周最大/最小工作时间
- html - Bootstrap 导航栏垂直分隔线
- javascript - pouchDB 查询在导出的异步函数中使用时返回空对象
- typescript - kotlin 标准库有打字稿定义吗?