Richard Garfield Richard Garfield - 1 year ago 92
HTML Question

How to change property of a tag in html with javascript

I have:

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

I can change the href property with:

element.href = "what I want";

but when I do = "what I want";

it doesn't work.

Does anyone know how I can change the download property?


Answer Source

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

Use Element#setAttribute method to update an attribute.

element.setAttribute('download', "what I want");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download