I'm using javascript to create dynamic fields as part of a larger form.
In the form the user can add additional names to the form by clicking a button and filling in the extra names.
My code works fine in JSFiddle, but when I test this on my code editor the jQuery doesn't work in Live Preview (I use Brackets). I've tried disabling Lint File.
I have a feeling it could be how I have my code editor / file set up but unsure. Help would be much appreciated!
Link to working JSFiddle - http://jsfiddle.net/0pbeuksL/
HTML
How I've linked my JS
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="access.js"></script>
The relevant section of the form
<p> Site Attendees</p><br>
<div class="container1">
<button class="add_form_field">Add Attendee
<span style="font-size:16px; font-weight:bold;">+ </span>
</button>
<div><input type="text" name="personsundertakingworks" id="personsundertakingworks" placeholder="Name"></div>
</div>
JS
function addFields(){
var number = document.getElementById("member").value;
var container = document.getElementById("container");
while (container.hasChildNodes()) {
container.removeChild(container.lastChild);
}
for (i=0;i<number;i++){
container.appendChild(document.createTextNode("Member " + (i+1)));
var input = document.createElement("input");
input.type = "text";
container.appendChild(input);
container.appendChild(document.createElement("br"));
}
}