javascript - How to dynamically change the value of the <a> 'download' field in HTML? -
i have following:
author<input type="text" name="author" id="authortxt"><br> filename<input type="text" name="filename" id="filenametxt"><br> email<input type="text" name="email" id="email"> <img id="saveicon" src="interface/saveicon0.png" onmouseover="this.src='./interface/saveicon1.png'" onmouseout="this.src='./interface/saveicon0.png'" /> <img id="cancelicon" src="interface/cancelicon0.png" onmouseover="this.src='./interface/cancelicon1.png'" onmouseout="this.src='./interface/cancelicon0.png'" /> <a id="download" download="testjson-r.json">download</a> i need filename of download set 'filename' field. simplest way of doing this?
try use .attr() , .val() on respective elements accomplish task,
$("#download").attr("download", $("#filenametext").val())
Comments
Post a Comment