【问题标题】:How to change property of a tag in html with javascript [duplicate]如何使用javascript更改html中标签的属性[重复]
【发布时间】:2017-04-13 21:36:30
【问题描述】:

我有:

<a id="save-button" href="data:application/xml;charset=utf-8,your code here" download="test.cod">Save</a>

我可以更改 href 属性:

element.href = "what I want";

但是当我这样做时

element.download = "what I want";

它不起作用。

有人知道如何更改下载属性吗?

谢谢

【问题讨论】:

  • 试试 element.setAttribute("download", "what I want")

标签: javascript html


【解决方案1】:

The download property is not supported widely which is still an experimental API.


使用Element#setAttribute 方法更新属性。

element.setAttribute('download', "what I want");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 2014-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多