[jQuery] Re: jquery and math functions

2008-02-22 Thread timothytoe
For most simple cases, I use a prefix of a unary plus to convert strings to numbers. It's short. It's easy to read once you're used to doing it. I haven't tested the speed, but it may be faster as well. >>> typeof("1"); "string" >>> typeof(+"1"); "number" var startmin = (+$("timestartmin").text(

[jQuery] Re: jquery and math functions

2008-02-22 Thread Dan G. Switzer, II
Vlad, >Is there something special that needs to be done to values selected with >jQuery so math functions can work on them? parseInt or something? I am not >sure, but all my calculations are getting NaN. For example, I have the >following function that always produces NaN: > >var star

[jQuery] Re: jquery and math functions

2008-02-22 Thread Klaus Hartl
On Feb 22, 7:03 am, Shawn <[EMAIL PROTECTED]> wrote: > var startmin = parseInt( $("timestartmin").text() ); > var stopmin = parseInt( $("timestopmin").text() ); > > //check to make sure you didn't get a NaN > if (!startmin) startmin = 0; > if (!stopmin) stopmin = 0; > > The second part where the s

[jQuery] Re: jquery and math functions

2008-02-21 Thread Shawn
Yep - parseInt() or parseFloat(). When you are pulling data from HTML you will get something like "55" rather than 55 (notice the quotes). So then doing something like this: var count = $("#mydiv").text() + 100; WOuld result in count being set to "55100" (assuming the div had 55 in it). A