|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
DOM 2 (question about CSS)
I am able to do this, to retrieve a value as a string:
Code:
//(IE version)
document.styleSheets[0].rules.item(0).style.getPropertyValue('width');
This will give me a string, e.g. '100px' But what I want is just the numeric value, i.e. 100, so that I can use it in a math formula. How can I do this? Thanks. |
|
#2
|
|||
|
|||
|
A simple
parseInt(thewholelineyoualreadyhave) will do. Jeroen |
|
#3
|
|||
|
|||
|
You could make it Mozilla-compatible as well:
var ss = document.styleSheets.item(0); var rules = ss.cssRules || ss.rules; var width = parseInt(rules.item(0).style.width); |
|
#4
|
||||
|
||||
|
Excellent! Thanks a lot!
![]()
__________________
Hello, old friend... |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > DOM 2 (question about CSS) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|