SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2013
    Location
    Istanbul,Turkey
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by sweetysweety View Post
    i'm trying to add 5px to leftPos and assign the result of it
    If it is $el that you are wanting to adjust, you can do it with jQuery via the .css() method

    Code javascript:
    $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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2013
    Location
    Istanbul,Turkey
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by sweetysweety View Post
    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
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2013
    Location
    Istanbul,Turkey
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by sweetysweety View Post
    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?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2013
    Location
    Istanbul,Turkey
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by sweetysweety View Post
    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?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Enthusiast
    Join Date
    Apr 2013
    Location
    Istanbul,Turkey
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the panel should begin to show itself under the 1st block.that's what i wanted.


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
  •