Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  65] [ 4]  / answers: 1 / hits: 40550  / 15 Years ago, thu, july 2, 2009, 12:00:00

Any ideas how I would go about writing a javascript method to insert an attribute to a tag



eg. I have



<input id='in1' value='Submit' type='submit'/>


and I want to insert an attribute name



<input id='in1' name='submit_content' value='Submit' type='submit'/>


Thanks


More From » html

 Answers
1

Try this:



document.getElementById(in1).setAttribute(name, submit_content);

[#99204] Friday, June 26, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrellhunterm

Total Points: 82
Total Questions: 109
Total Answers: 98

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
terrellhunterm questions
Mon, Aug 31, 20, 00:00, 4 Years ago
Mon, Aug 5, 19, 00:00, 5 Years ago
Thu, Apr 4, 19, 00:00, 5 Years ago
Mon, Mar 11, 19, 00:00, 5 Years ago
;