Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increment css top property using jquery

Tags:

jquery

css

I have the following div :

<div id="new" style="position: absolute; z-index: 100; top: 210px; width: 195px.. 

What is the best way to increase the top property when an event occurs?

Note that I've tried: $('#new').css('top')+10 but the problem is that .css returns string.

like image 774
ahmad Avatar asked Dec 05 '10 14:12

ahmad


1 Answers

The simplest way is to use the += operator:

$( '#new' ).css( 'top', '+=10px' ); 
like image 61
Steve Taylor Avatar answered Oct 11 '22 06:10

Steve Taylor