0

how do i remove the first attribute?

when i run my code, after clicking on an operator its supposed to switch the current onclick attribute to a different one however when it try it says that i have to clone it. https://code.sololearn.com/W82TiRfzwPnf/

16th Apr 2019, 10:59 PM
Tyrell Reid
Tyrell Reid - avatar
3 Answers
+ 4
Tyrell [Edited]I had to edit because honestly, I'm somewhat perplexed by your code. But that's neither here or there. To start off you not removing the "onclick" attribute, you are removing a class attribute. The next problem I see is that the inp element collection starts at index 1 instead of zero. This element collection is like an array in that its index also starts a zero. This will cause other problems like the 1 button not to work when you change over to entry2. To get rid of the error message I suggest replacing "setAttributeNode" with setAttribute, if you decide to do so you will need to pass the attribute name and value: setAttribute("onclick", "calculate.entry2(this)").
16th Apr 2019, 11:58 PM
ODLNT
ODLNT - avatar
+ 1
Thanks a lot, will try this out
17th Apr 2019, 5:55 AM
Tyrell Reid
Tyrell Reid - avatar
+ 1
OK I tried it and it fixed my problem, I think this may be the most functional calculator I've made so far because of you. Thanks.
17th Apr 2019, 7:33 PM
Tyrell Reid
Tyrell Reid - avatar