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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -