JavaScript JavaScript function that grabs element not working javascript function that returns a function,javascript function that returns

So I'm trying to make a function that grabs a HTML element and then after I've selected the HTML element I try to apply CSS to it via JavaScript but it doesn't seem to work. Instead, I get an error that says "Uncaught TypeError: Cannot read property 'style' of undefined". What am I doing wrong?

document.querySelector('h1').style.color = 'brown';

(this works though)

Wardrobe.js:

function qSelector(element) {
    document.querySelector(element);
}

qSelector('h1').style.color = 'brown';

index.html:

<html>
    <head>
    </head>
    <body>
        <h1 id="thing">Header 1</h1>
        <script src="Wardrobe.js"></script>
    </body>
</html>

I expect the color of <h1> to be brown but it's still black.

Answer:1

I tried to load a page inside my phonegape aplication with Jquery .load() but it doesn't work since it's not on a server and it's on local machine. When I'll upload the app on build. phonegape my ...

I tried to load a page inside my phonegape aplication with Jquery .load() but it doesn't work since it's not on a server and it's on local machine. When I'll upload the app on build. phonegape my ...

  1. phonegap load local html file
  2. phonegap load local file

I need to input this code through CKEditor: <ruby>niroj adhikary<rp>(</rp><rt>this is name</rt><rp>)</rp></ruby> CKEditor is not accepting ...

I need to input this code through CKEditor: <ruby>niroj adhikary<rp>(</rp><rt>this is name</rt><rp>)</rp></ruby> CKEditor is not accepting ...

I'm trying to put circles in svg dynamically. In index.html file I created this svg section. <svg id="svgArea" width="500" height="500"></svg> In js file i tried this $('#svgArea')....

I'm trying to put circles in svg dynamically. In index.html file I created this svg section. <svg id="svgArea" width="500" height="500"></svg> In js file i tried this $('#svgArea')....

  1. circle elementary
  2. circle elementary school
  3. circle element html
  4. circle element svg
  5. circle elementary school wichita ks
  6. circle element css
  7. circle elementor
  8. circle elements vector
  9. circle elementary greenwich
  10. circle elementary towanda ks
  11. circle elementary school mt
  12. circle elementary wichita ks
  13. circle elementary school kansas
  14. circle elementary school benton ks
  15. circle elemental symbols
  16. circle element attributes
  17. circle elements radius
  18. circle element design
  19. circle element android
  20. circle element logo

I was working on the code of a practice for React, but I stopped because I have to make a navigation bar be shared among other pages I found the next solution and it works but I don't know how ...

I was working on the code of a practice for React, but I stopped because I have to make a navigation bar be shared among other pages I found the next solution and it works but I don't know how ...