Elindo
Coder
So, I got a code for add and remove fieldsets from a from.
The code works great on codepen, but when I got testes on vscode with the google console, well it doesn't work!!!
On codepen I can add and remove elements, but once I take it to the Google console it doesn't response to elements that have been deleted and I can't add it back on.
Even if the element exist in the html file, once it doesn't show in the screen, then the element seems to be lost and the code can't find it in Google console...... not the case in Codepen.io , even if the item is removed from the screen, the code can still find it and add it back on.
Check out these two functions... why would this code work in Codepen, but not Google Console?
The code works great on codepen, but when I got testes on vscode with the google console, well it doesn't work!!!
On codepen I can add and remove elements, but once I take it to the Google console it doesn't response to elements that have been deleted and I can't add it back on.
Even if the element exist in the html file, once it doesn't show in the screen, then the element seems to be lost and the code can't find it in Google console...... not the case in Codepen.io , even if the item is removed from the screen, the code can still find it and add it back on.
Check out these two functions... why would this code work in Codepen, but not Google Console?
Code:
const f2parent = document.getElementById ("parentfieldset");
const f22pump = document.getElementById ("fieldsetpump2");
const f23pump = document.getElementById ("fieldsetpump3");
const remove2pump = f2parent.removeChild(f22pump);
const remove3pump = f2parent.removeChild(f23pump);
const add2pump = f2parent.appendChild(remove2pump);
const add3pump = f2parent.appendChild(remove3pump);
function singlePumpf (){
if(document.getElementById ("pump1").checked) {
f2parent.removeChild(f22pump);
f2parent.removeChild(f23pump);
}
}
function doublePumpf(){
if(document.getElementById ("pump2").checked) {
const f2parent = document.getElementById ("parentfieldset");
const f22pump = document.getElementById ("fieldsetpump2");
const f23pump = document.getElementById ("fieldsetpump3")
f2parent.appendChild(remove2pump);
f2parent.removeChild(f23pump);