I have a function:
function controls() {
var block = $('#controls');
block.html('');
block.append('<button type="button" onClick="focus(this.value);" id="viewAll" value="all">View All</button> <br><br>');
for (var i = 0; i < markers.length; i++) {
block.append(
'<label><input id="drones" type="radio" onClick="focus(this.value);" name="drones" value="' + markers[i].title + '" /> Focus on: ' + markers[i].title + ' </label><br>'
);
}
}
It dynamically adds html elements into the div.
I want to get the value for the item that i clicked on.
But im getting this error:
Uncaught TypeError: Failed to execute 'focus' on 'HTMLElement': parameter 1 ('options') is not an object. at HTMLButtonElement.onclick (map 2.html:1) onclick @ map 2.html:1
The source window in chrome is reporting: focus(this.value);
my focus function:
function focus(drone) {
console.log(drone);
}
Please help.