I am trying to use a function with click(). I get no errors in the console how can I make it so that when the click happens it will perform the action in the function? Here is the code I am working with.
inputIds = [].filter.call(document.getElementsByTagName('input'), function(el) {
return el.id.indexOf('ansx') === 0;
}).map(function(el) {
return el.id;
});
// random number between low and high range
inputId = inputIds[Math.floor(Math.random() * inputIds.length)];
document.getElementById(inputId).click(function() {
chrome.extension.sendMessage({ message: "text here" }, function(response) {
return response;
});
});
return response;isn't actually doing anything.