javascript - Get css value without DOM element -


I'm thinking that there is a way to get the CSS value from a stylesheet file when no element in the DOM does not use it Used to be? I am using jQuery and I use the selector $ ("classname"). But with the case "classname" is not in any element, "thanks"

just for that class Create an element with the name and observe it. You do not even need to attach it to the DOM:

  var $ el = $ ('& lt; div class = "classname" & gt; & lt; / div & Gt; '); Var opacity = $ el.css // ' 

although the $ el does not actually exist in the DOM, yet you can You can gain access to all styled properties.


Edit : As stated in the observations, this approach does not always work because for example #foo failed For example the selector specification is moving more than a standalone

code> .bar :

CSS:

  # Foo .bar {color: red;}  

js: $ El.css ('color'):

  var $ el = $ (' & Lt; div class = "bar" & gt; & lt; / div & gt; ')); // Expected: "Red", Actual: ""  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -