Reputation: 189
I'm trying to use chrome.tabs.executeScript to target a specific div on my page.
function click(e) {
chrome.tabs.executeScript(null,
{code:"document.body.div#wrap.style.color='" + e.target.id + "'"});
window.close();
}
Consule is telling me: Uncaught SyntaxError: Unexpected token ILLEGAL
Is this a syntax problem, or is this not possible?
Upvotes: 0
Views: 276
Reputation: 349142
Use document.querySelector
instead of the syntactically invalid div#wrap
:
chrome.tabs.executeScript(null, {
code: "document.querySelector('div#wrap').style.color='" + e.target.id + "';"
});
Upvotes: 2