How to add update an attribute to an HTML element using JavaScript

0 votes
I'm trying to find a way to add / update attributes using JavaScript. I know I can do it with setAttribute() function but that doesn't work in IE.
Aug 2 in HTML by Ashwini
• 1,160 points
27 views

1 answer to this question.

0 votes

You can read here about the behaviour of attributes in many different browsers, including IE.

element.setAttribute() should do the trick, even in IE. Did you try it? If it doesn't work, then maybe element.attributeName = 'value' might work.

answered Aug 4 by Deepak
• 940 points

Related Questions In HTML

0 votes
0 answers

How to do calculations in HTML forms using JavaScript?

I'm developing a straightforward app that multiplies ...READ MORE

Jul 26 in HTML by Tejashwini
• 1,960 points
98 views
0 votes
0 answers

How do I add my logo to my website using html

I already have a website set up, ...READ MORE

Aug 8 in HTML by Tejashwini
• 540 points
74 views
0 votes
0 answers

How to style the option of an html "select" element?

Here's my HTML: <select id="ddlProducts" name="ddProducts"> ...READ MORE

Aug 17 in HTML by Deepak
• 940 points
29 views
0 votes
0 answers

How to hide image broken Icon using only CSS/HTML?

I need to hide this error image/ ...READ MORE

May 27 in HTML by Tejashwini
• 1,960 points
156 views
0 votes
0 answers

How to add/update an attribute to an HTML element using JavaScript?

I'm looking for a JavaScript method to ...READ MORE

Aug 1 in HTML by Ashwini
• 1,160 points
35 views
0 votes
1 answer

How to store an array in localstorage?

Localstorage only supports Strings. So you can ...READ MORE

answered Jul 1, 2019 in Others by sunshine
• 1,280 points
19,546 views
0 votes
1 answer
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,510 points
436 views
0 votes
1 answer

How to trigger a file download when clicking an HTML button or JavaScript?

For the button you can do <form method="get" ...READ MORE

answered Aug 4 in HTML by Deepak
• 940 points
312 views
0 votes
1 answer

How to set a border for an HTML div tag?

 you can use border-width:2px; border-style:solid; border-color:black; or as shorthand border: 2px solid ...READ MORE

answered Aug 4 in HTML by Deepak
• 940 points
28 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP