Jquery math operations

hi everyone

leftPos = Math.round($el.position().left);

i’m trying to add 5px to leftPos and assign the result of it to
left:leftPos+5px

how can i do this?

If it is $el that you are wanting to adjust, you can do it with jQuery via the .css() method


$el.css('left', '+=5');

As it says there:

As of jQuery 1.6, .css() accepts relative values similar to .animate(). Relative values are a string starting with += or -= to increment or decrement the current value. For example, if an element’s padding-left was 10px, .css( “padding-left”, “+=15” ) would result in a total padding-left of 25px.

http://www.terranartworks.com/Example/index.html

i’m trying to start the red panel appearing under the buttons from the box on the left of first button.

There are too many levels of indirection in that statement making my brain feel numb so can you please rephrase?

Are you wanting the red panel to start the red panel underneath the buttons and to then have it pop up to the same level of the buttons?
Or, are you wanting the red panel to start at a similar distance from the left button, as it is from the next?
Or is it something else?

If it’s the middle option, you can just make it visible and set its left position to be the same as its width, that being 47px

i’m tryin to sayin the colorful panel will slide,when i click at at any button and come under the button’s position.
but it begin to slide under the 1st block.
i made it begin at 47px position but when i clicked some button it comes 47px left of that button.i do not want this.i want it to stop under the buttons location.

Okay, thanks for clearing that up. It seems to work perfectly well when I view it in google chrome, so it appears that you may be experiencing a bug in the web browser that you are using.
Which web browser are experiencing the issue with?

no no it is not working perfect.when you press the button,the panel appears a low opacity at the beginning.i don’t want to see this situation.

What do you want instead?

the panel should begin to show itself under the 1st block.that’s what i wanted.