Tip Precoz: obtener valor numérico con JavaScript

11/Abr/2012 227

Con jQuery constantemente necesitamos crear variables para tomar valores CSS de elementos, para luego construir nuevos elementos o interacciones; constantemente lo hago en plugins cono Timelinr o Blox!, pero JavaScript nos ofrece un método más rápido que el andar haciendo slices.

Desde el siguiente ejemplo, tomaremos la el valor CSS de margin-top del buscador de este mismo sitio; normalmente lo haríamos de esta manera:

var marginT = $('#search_container').css('margin-top');

Click para ver ejemplo 1

Ejemplo1: obtener valor numérico con JavaScript

El valor entregado efectivamente es el correcto: 10px pero lo necesitamos numérico. Para ello utilizamos replace():

var marginT = $('#search_container').css('margin-top').replace('px','');

Click para ver ejemplo 2

Ejemplo2: obtener valor numérico con JavaScript

Comentarios

  1. bdsm gay dating sites [#]

    gay dating sites diktek https://dating-gaym.com/

  2. HenryUnfiP [#]

    our time gay dating
    gay dating online philippines
    gay firefighter dating site

  3. ivermectin1.com [#]

    ivermectin मानव को लागी Tip Precoz: obtener valor numerico con JavaScript | CSSLab | Laboratorio de ideas web https://ivermectin1.com/ ivermectin for humans dosage

  4. hydroxychloroquineMt [#]

    chloroquine pills hidroxicloroquina hydroxychloroquine sulfate uses

  5. vgl gay dating [#]

    gay dating in qatar https://datinggayservices.com/

  6. gay master slave dating sites [#]

    gay dating decoded https://gaydatinglosangeles.com/

  7. a quest bars [#]

    Fine way of telling, and nice piece of writing to take information concerning my presentation topic,
    which i am going to present in university. quest bars http://tinyurl.com/49u8p8w7 quest bars

  8. your quest bars [#]

    Thanks for sharing your thoughts on or. Regards quest bars http://bitly.com/3jZgEA2 quest bars

  9. app.gumroad.com [#]

    What’s up to all, the contents existing at this site are
    really remarkable for people knowledge, well, keep up the nice
    work fellows. asmr https://app.gumroad.com/asmr2021/p/best-asmr-online asmr

  10. bitly.com [#]

    I have read so many articles on the topic of the blogger lovers but this
    article is genuinely a fastidious piece of writing, keep it up.
    cheap flights http://1704milesapart.tumblr.com/ cheap flights

  11. http://www.iherb.com [#]

    Hi there! I simply wish to give you a huge thumbs up
    for the great info you have right here on this post.
    I’ll be returning to your website for more soon. quest bars https://www.iherb.com/search?kw=quest%20bars quest
    bars

  12. tinyurl.com [#]

    I do not even know the way I ended up right here, however I
    thought this publish used to be good. I do not know who you are however definitely you are going to a famous blogger if you aren’t already.
    Cheers! ps4 https://bit.ly/3z5HwTp ps4

  13. bit.ly [#]

    Hi it’s me, I am also visiting this web page daily, this site is genuinely fastidious and
    the viewers are really sharing pleasant thoughts.

    scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery

  14. bitly.com [#]

    This piece of writing is genuinely a pleasant one it helps new net viewers, who
    are wishing for blogging. scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery

  15. http://bit.ly/3C42OCu [#]

    you are in point of fact a excellent webmaster. The website
    loading speed is amazing. It sort of feels that you
    are doing any distinctive trick. Moreover, The contents are masterwork.

    you’ve performed a fantastic job in this topic! cheap flights http://1704milesapart.tumblr.com/ cheap
    flights

  16. HenryUnfiP [#]

    gay dating sites for teens
    top gay dating sites 2021
    fuck buddies gay dating

  17. http://coub.com/ [#]

    It’s very straightforward to find out any matter on web
    as compared to textbooks, as I found this post at this
    website. scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

  18. HenryUnfiP [#]

    gay furry dating discord
    wales gay dating
    stardom site dating gay

  19. best generic cetirizine [#]

    $7 zyrtec coupons printable – https://allergyd.com

  20. where can i buy cetirizine [#]

    zyrtec allergy 10 mg – http://allergyd.com

  21. what is allegra [#]

    xyzal samples for providers – http://allergyd.com

  22. stromectolforte.com [#]

    ivermektiini otc http://stromectolforte.com/ stromectol tablets ivermectina

  23. stromectolforte.com [#]

    ivermectin over the counter in the us https://stromectolforte.com/ buy ivermectin 12 mg for humans comprimido de estromectol

  24. ivermcov.com [#]

    medical doctor degree http://ivermcov.com – generic stromectol

  25. wardenafil.com [#]

    doctor medical school http://wardenafil.com – levitra tablets price in india

  26. use of ivermectin in humans [#]

    Thanks to my father who stated to me regarding this web site, this website is
    in fact amazing. http://harmonyhomesltd.com/Ivermectinum-side-effects.html

  27. stromectolforte.com [#]

    ivermectina en humanos https://stromectolforte.com/ ivermectin 1% cream generic stromectol

CSSLab