While exploring Chrome extensions, I came across a strange issue with the popup window.
Inside popup.html, there is an element
<a id="grantexpert">...</a>
and in popup.js, I want to change the background color of this element when clicked. Initially, changing the color immediately after document ready works fine. However, during the click event, the color changes briefly (just a blink) and then reverts back to its original state. It seems like the popup window is being reloaded after each click event.
Manifest:
"browser_action": {
"default_popup": "popup/popup.html"
},
popup.html:
<!DOCTYPE html>
<head>
<script src='../other/jquery-3.1.1.min.js'></script>
<script src='popup.js'></script>
</head>
<body style="width:250px;">
<a class="testitem" href id="grantexpert">grantexpert.sk</a>
</body>
</html>
popup.js:
(function($) {
$(document).ready(function() {
//$("#grantexpert").css('font-size', '28px'); - this works
// this does not work
$('#grantexpert').click(function () {
$(this).css('font-size', '28px');
});
});
})(jQuery);
Why does the element change color momentarily on click but fail to retain the modified properties afterwards?