I have the follwing variable:
var workerId = "worker1";
I also have this div:
<div role="tabpanel" class="tab-pane" id="worker1">
Is it possible to update my variable to use the id from the div rather than hard coding the value?
I have the follwing variable:
var workerId = "worker1";
I also have this div:
<div role="tabpanel" class="tab-pane" id="worker1">
Is it possible to update my variable to use the id from the div rather than hard coding the value?
If that element class is unique you can get the element by class and read the id from that element:
const el = document.getElementsByClassName('tab-pane');
const workerId = el[0].id;
console.log(workerId);
<div role="tabpanel" class="tab-pane" id="worker1">