This is the js code I have put in a content script named ‘detectclicks.js’ to detect clicks on any portion of a web page open in the browser- it uses Jquery— However no alert is being displayed…
$('body').on('click', '*', function(event) {
window.alert(' ID of element- testing');
window.alert(' ID of element=' + $(this).attr('id')); // Get ID attribute
window.alert(' ID of Parent element=' + $(this).parent()..attr('id'));
});
And this is my manifest.json–
{
"name": "My First Extension",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["jquery1.7.2.js", "detectclicks.js"]
}
],
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
No alert is being displayed when I load this extension into Google Chrome and visit a web page..click on any part of the page…What am I doing wrong here?
As discussed in the comments, check it should not be double dots in this line:
Be attentive! 😉