I have the following code in the of the page (along with other tags) and I want eventually to retrieve the numeric value of "z-index" into a variable:
<style>
.main_style {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#CCC;
text-align:center;
border:7px solid #333;
-moz-border-radius:5px /;
border-radius:5px / 5px;
background-color:#333;
z-index:1000;
width:auto;
min-width:0;
max-width:1000px;
height:auto;
min-height:0;
max-height:1000px;
margin:0;
}
</style>
I thought of the following (with jQuery and Javascript) but I am sure it is not the most efficient way to do this:
var a1=$("style:contains('.main_style')").html();
var a2=+a1.match(/z-index: (\d*?);/i)[1];
Here is its FIDDLE: http://jsfiddle.net/R2S4q/
Any other ideas on what is the best approach?