dpjollygreen
Coder
So I've got this linked list that has hyperlinks that run a function. I'm trying to get a specific item to show a modal for choices associated with the item. Below I've added the pertinent parts of the code that populate the list as well as the function call that should show the modal. I seem to be having trouble referencing the item in question to trigger the btn that'll make the modal work. These items are in separate functions.
Creation______________
const ropeString = /Rope/g;
const matchRope = inventoryString.match(ropeString);
let numRopes = matchRope.length;
// document.getElementById("test2").innerHTML = numRopes;
for(let i = 0; i < numRopes; i++){
let rope = document.createElement('li');
let ropeLink = document.createElement('a');
ropeLink.textContent = "Rope";
ropeLink.href = "#";
ropeLink.id = "rope";
ropeLink.href = "javascript:useRope()";
rope.appendChild(ropeLink);
listInv.appendChild(rope);
}
Use______________
Creation______________
const ropeString = /Rope/g;
const matchRope = inventoryString.match(ropeString);
let numRopes = matchRope.length;
// document.getElementById("test2").innerHTML = numRopes;
for(let i = 0; i < numRopes; i++){
let rope = document.createElement('li');
let ropeLink = document.createElement('a');
ropeLink.textContent = "Rope";
ropeLink.href = "#";
ropeLink.id = "rope";
ropeLink.href = "javascript:useRope()";
rope.appendChild(ropeLink);
listInv.appendChild(rope);
}
Use______________