admin管理员组文章数量:1394164
inspired from Google dictionary plugin
Chrome extension : How to get / detect click events on any page or any where. just like Google Dictionary Plugin does?
eg. click on a table or a form etc.
Here is the code ,
$(".myTable").on('click', 'tr', function () {
var trValue = $(this).attr('value');
var tdValue = $(this).children('td').map(function (index, val) {
return $(this).text();
}).toArray();
console.log(tdValue);});
inspired from Google dictionary plugin
Chrome extension : How to get / detect click events on any page or any where. just like Google Dictionary Plugin does?
eg. click on a table or a form etc.
Here is the code ,
$(".myTable").on('click', 'tr', function () {
var trValue = $(this).attr('value');
var tdValue = $(this).children('td').map(function (index, val) {
return $(this).text();
}).toArray();
console.log(tdValue);});
Share
Improve this question
edited Mar 4, 2016 at 6:10
K.Karthik
asked Mar 4, 2016 at 5:48
K.KarthikK.Karthik
31 silver badge4 bronze badges
3
- 1 what u have done so far? – xkeshav Commented Mar 4, 2016 at 5:52
- The below code is for getting data from a table. my requirement is , I should be able to get data from any table of any page in any tab. $(".myTable").on('click', 'tr', function () { var trValue = $(this).attr('value'); var tdValue = $(this).children('td').map(function (index, val) { return $(this).text(); }).toArray(); //alert(tdValue); });*/ – K.Karthik Commented Mar 4, 2016 at 6:01
- @K.Karthik, hi, if my answer has helped, please consider accepting the answer, thanks – Haibara Ai Commented Mar 8, 2016 at 2:26
1 Answer
Reset to default 6You could use content script, remember to set "matches": ["<all_urls>"]
in manifest.json, it means you content script will be injected into every page.
In your content script, you can listen to click event and do what you want
document.addEventListener("click", function() {
// Do what you want with click event
}, false);
本文标签:
版权声明:本文标题:javascript - Chrome extension : How to getdetect click events on any page or any where. just like Google Dictionary Plugin does? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744694570a2620199.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论