Can we modify the attribute’s value of the HTML tag dynamically? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can we modify the attribute’s value of the HTML tag dynamically?

6th Nov 2020, 2:17 AM
7fadil
7fadil - avatar
5 Answers
0
Yes, we can modify the value of the attributes by using JavaScript. Below is the input element whose attribute will be modified from text to password, JS code to modify the attribute value: <input type=“text” id=“inputField”> document.getElementById(“inputField”).attr(“type”, “password”);
6th Nov 2020, 2:27 AM
7fadil
7fadil - avatar
+ 6
Salihu Ismail jibril it is .getAttribute or .setAttribute instead of .attr .attr is found in jquery
6th Nov 2020, 4:23 AM
maf
maf - avatar
+ 6
Is this some kind of self-answer spam?🤔 Salihu Ismail jibril Please don't ask a question when you know the answer beforehand. It's dull
6th Nov 2020, 5:35 AM
Kevin ★
+ 4
6th Nov 2020, 2:34 AM
Ipang
+ 2
Yes, you can use javascript. By calling dom
6th Nov 2020, 4:59 AM
Steve Sajeev
Steve Sajeev - avatar