0

Is there a way to setAttribute() on an element where the attribute name can be camelCase..!? eg:
present: element.setAttribute("myAttr","myattrValue");
results: <p myattr="myattrValue"/>

Can the attribute be set in the camelCase..?
looking for something like: <p myAttr="myattrValue"/>
elementNamespaceURI : xhtml/1999

Edit:
another example: <input type="text" onClick="func()"/> is what I am looking for, where as
<input type="text"/> will be given as source, and have to setAttribute()..
which is onClick
but now it's onclick...!

"Onclick", is just an example to showcase, where both onClick & onclick will yield same result..But the need is attribute camelCase as it is set!

Help me find solution...!

peaceUser
  • 457
  • 5
  • 19
  • What is purpose of setting uppercase attribute name? – guest271314 Oct 12 '16 at 07:22
  • case is to perform a generic way of attribute access across various frameWorks. @Mohammad : there is explanation of HTML specs, but not solution/ a workaround. – peaceUser Oct 12 '16 at 07:26
  • 1
    Sounds like you just got a habit to kick to me... you keep spelling arbitrary words in camel case for no apparent reason, and if you just stopped doing that you wouldn't be having this problem. – BoltClock Oct 12 '16 at 07:38
  • 1
    For the record, the XHTML namespace has nothing to do with any of this. HTML elements are always represented as being in the XHTML namespace whether your page is in HTML or XML mode. In fact, were your page in XML mode, you would in fact see myAttr being reflected in the correct case. – BoltClock Oct 12 '16 at 07:43
  • @BoltClock , lolz... apparently I am kicked off with this problem.. :) The solution for this problem can be a mark for any one who is searching for in near future..! ;) – peaceUser Oct 12 '16 at 07:45
  • 2
    Neither `myAttr`, `myattr` nor `onClick` are in the XHTML namespace. The first two simply don't exist and `onclick` is explicitly all lower case. – Quentin Oct 12 '16 at 09:51
  • After all the comments, it's still unclear what you want to achieve. On the one hand it sounds like switching your file type to actual XHTML will result in what you want; you can give elements attributes in the case you want and they won't change case. However, then you start about `onClick`, and, well, giving an element an `onClick` attribute in XHTML won't _do_ anything; it will just be useless garbage. So, what do you want?? – Mr Lister Oct 12 '16 at 12:52
  • Simply I am trying to set an attribute to a dom element, in camelCase. Which is not happeneing, even if I set, it is converting to lowercase. – peaceUser Oct 12 '16 at 13:01
  • @peaceUser Why do you want that? – Mr Lister Oct 12 '16 at 14:12
  • I am afraid that even if I tell the reason n-times like above it will not happen and it seems like a debate topic rather a problem and resolution..! – peaceUser Oct 12 '16 at 14:20

0 Answers0