admin管理员组

文章数量:1200979

I create elements with the var l = document.createElement("label"); and I assign its attributes with l.setAttribute("formControlName","e");. The problem is that the setAttribute method puts the formControlName in lowercase letters as you can see in the image below. I work with ionic so the capital letters are needed. Does anyone see what I did wrong?

I create elements with the var l = document.createElement("label"); and I assign its attributes with l.setAttribute("formControlName","e");. The problem is that the setAttribute method puts the formControlName in lowercase letters as you can see in the image below. I work with ionic so the capital letters are needed. Does anyone see what I did wrong?

Share Improve this question edited May 8, 2020 at 7:22 mvermand 6,1178 gold badges49 silver badges78 bronze badges asked Jan 17, 2018 at 11:57 BrianMBrianM 9492 gold badges13 silver badges31 bronze badges 3
  • 3 Possible duplicate of Camel case in HTML tag attributes and jquery - doesn't work, why? – Adelin Commented Jan 17, 2018 at 11:59
  • 1 Do you have a reference for "ionic so the capital letters are needed"? I find that hard to believe. – Nickolay Commented Jan 23, 2018 at 16:37
  • This is rather a requirement of Angular which is a framework below Ionic. – mvermand Commented May 8, 2020 at 7:20
Add a comment  | 

1 Answer 1

Reset to default 28

Use this instead:

l.setAttributeNS(null, "formControlName","e");

'setAttributeNS()' doesn't convert the name to lower case.

本文标签: javascriptsetAttribute makes the attribute name lowercaseStack Overflow