How To 'split' A Css Attribute/value Using Jquery
I am currently a little stuck with 'splitting' a css value in Jquery. I have a div styled like: in which I want the 'level' of the tank to move dynamically using jquery. i am tryi
Solution 1:
Try using .split()
as show :-
myVal = myVal.split(" ")[4]
above shown code will give you output as -200px
but if you want only -200
then use parseInt()
myVal = parseInt(myVal,10);
EDIT :-
If IE is giving different css property string then you can detect the browser and see if it's IE then use [2]
index otherwise [4]
index.
OR you can try something like this :-
if((myVal.split(" ")[2]).indexOf(")") >= 0){
myVal = myVal.split(" ")[4]
}
else{
myVal = myVal.split(" ")[2]
}
Post a Comment for "How To 'split' A Css Attribute/value Using Jquery"