I’m writing an extension for chrome as “Content script”. My extension should change the background color of google home page (https://www.google.com)
I wrote this code (including jquery):
$(".gsib_a").style="background:#FF0000";
But not worked. I’m sure I added jQuery to content script, and the manifest.json file is set. I am sure because this code works:
$(".gsib_a").hide();
And I am sure changing style of the element with class of gsib_a is exactly what I need and affects. Because I’ve tested it by Chrome Developer Tools.
Okay, who knows the problem?
if you want to change an attribute, use the attr method:
$('.gsib_a').attr('style','background-color:#FF0000');but you can change the css directly with the css method: