Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
    .test {
      width:100px;
      height:100px;
      background:red;
      opacity:0.5;
    }
  </style>
</head>
<body>
  <div class="test"></div>
</body>
</html>
 
function getStyle(selector,styleProp) {
    var x = document.querySelector(selector).cloneNode(),
        y;
    if (x.currentStyle) {
        y = x.currentStyle[styleProp];
    } else if (window.getComputedStyle) {
        y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
    }
    return y;
}
console.log(getStyle(".test", "opacity"));
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers