Good afternoon, I wrote a plugin for chrome, like there is access from the DOM to the page tree from under it. ALERT using jQuery appears, but I just can not, change the style to block, tell me what I'm doing wrong:

Manifesto:

{ "name":" ПОИСК 1.1 ", "description":"ПОИСК ", "manifest_version":2, "version":"1", "permissions":["tabs","<all_urls>"], "browser_action":{ "default_icon":"icon.png", "default_popup":"popup.html" }, "web_accessible_resources": ["LeoScript.js"] , "permissions":["tabs","<all_urls>"] } 

Popup:

 <html> <head> <script src="popup.js"></script> </head> <body> <input type="text" placeholder="найти"> <button type="submit" id="find" value="поиск"> НАЙТИ </button> </body> </html> 

Js:

 $(document).ready(function() { $("#find").click(function(){ $('.ng-hide').css('display', 'block!Important'); }); }); 

Background handler:

 document.addEventListener("DOMContentLoaded", function (){ chrome.tabs.executeScript( {"file": "LeoScript.js"}); }); 

    1 answer 1

    You can not assign !important in this way.

    Instead of $('.ng-hide').css('display', 'block!Important') you can use this:

     $('.ng-hide').each(function () { this.style.setProperty('display', 'block', 'important'); }); 

    Or you can overwrite the entire style attribute:

     $('.ng-hide').css('cssText', 'display: block !important'); 
    • Thanks, but something is not working, I also test the alert output: if just a “bare” alert, then it works as it should: alert ("111"); if in processing when clicking on a button, for some reason, $ ("# find") does not work. click (function () {alert ("111");}); - b.tard2016