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, 2022 in HTML by Ashwini
• 5,430 points
815 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, 2022 by Deepak
• 980 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, 2022 in HTML by Tejashwini
• 3,820 points
1,571 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, 2022 in HTML by Tejashwini
• 780 points
3,835 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, 2022 in HTML by Deepak
• 980 points
755 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, 2022 in HTML by Tejashwini
• 3,820 points
634 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, 2022 in HTML by Ashwini
• 5,430 points
565 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,300 points
23,027 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,520 points
935 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, 2022 in HTML by Deepak
• 980 points
3,077 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, 2022 in HTML by Deepak
• 980 points
738 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