SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    parseFloat() w/two args

    hi,

    I'm trying to implement jQuery a font-resize script

    got from here,
    http://dev-tips.com/featured/jquery-...-font-resizing

    my implementation is not working, and I'm trying to figure out what the 2nd argument in his parseFloat fn is

    Code:
     var finalNum = parseFloat(currFontSize, 10);
    (is it maybe the default font-size in my 'body' tag?)

    I searched for javascript parseFloat() fn, but have not found any examples of this fn with two arguments..

    thank you..

  2. #2
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    my implementation is attached.. I don't know why it's not working (for a split-second I saw a larger font when clicked on larger-font button, but it disappeared..)

    (for the 1st time attaching a file to my post since can't get to my ftp right now..it's just an HTML, all JS and CSS is in there.. (had to convert to .txt.. why can't you attach an .html file, it's just a text file..))

    thank you..
    Attached Files Attached Files

  3. #3
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    oh brother.. I got it.. since am binding to a link (not an input) had forgotten e.preventDefault..

    but I still have a few questions, I still would like to know what that 2nd arg is in parseFloat fn; I would like to know why for multiplying he has '*=' instead of just '*' (same thing for dividing..); and: I don't know if this can be done w/this script, I might have to use another script....

    they want on every click font-size to change by 1 px,, same thing going down (when you click on 'smaller font' button that font-size decrease by ONE pixel... is it possible to alter this script to do this?)

    (I multiply and divide in my example by 2 to make it more dramatic so I could see results clearly; it actually works pretty well with 1.2, but not sure that's what they want..)

    thank you very much...

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,809
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The purpose of both parseInt and parseFloat are to convert numers from one base (anywhere from base 2 to base 36) into numbers in base 10.

    Where the number in the first parameter starts with '0x' it is assumed to be base 16 if the base isn't specified in the second parameter. If it starts with a '0' it is assumed to be base 8 and if it starts with anything else it is assumed to be base 10. You get around these assumptions and can select any other number base between 2 and 36 by specifying the number base in the second parameter.

    If you are not sure what number bases are about then base 2 is bianry where all numbers are expressed using nothing but 0 and 1. Base 8 is octal which uses numbers from 0 through 7 and 8 is written as 010. Hexadecimal uses 0-9 and a-f to represent the numbers with 16 being written as 0x10. Base 26 uses all the numbers 0-9 and all the letters a-z to represent numbers up to 35 as a single digit.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •