Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6086817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:47:57+00:00 2026-05-23T11:47:57+00:00

This is my code: var lef=$(this).css(left); var top=$(this).css(top); alert(lef); $(this).after(<div class=’edit cancel’ style=’position:absolute;top:+top+;left:+lef+’>Cancel</div>); Now

  • 0

This is my code:

var lef=$(this).css("left");
var top=$(this).css("top");
alert(lef);
$(this).after("<div class='edit cancel' style='position:absolute;top:"+top+";left:"+lef+"'>Cancel</div>");

Now the statement var lef=$(this).css("left") + 150, doesn’t seem to work. I want to get the left property and add 150 pixels to it

How can i do this ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:47:58+00:00Added an answer on May 23, 2026 at 11:47 am

    Here’s the easiest way (for the general case):

    $(this).css('left', '+=150');
    $(this).css('top', '-=100');
    

    http://api.jquery.com/css/#css-properties

    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.


    If you need to do it “manually” (for example, as part of creating a new element):

    var left = parseInt($(this).css('left')) + 150;
    var top = parseInt($(this).css('top'));
    
    $(this).after('<div style="top: ' + top + 'px; left: ' + left + 'px; position: absolute">Cancel</div>');
    

    You need to use parseInt because .css('left') returns 150px. You then have to put back the px as part of the inline style.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: var pos = $(this).offset(); var width = $(this).width(); userPreviewCon.css({ left:
If I run this code - var html= '<html><head></head><body><div class=bar></div></body></html>'; console.log($(html).find('div')); I get no
I have this code: var $msg = jQuery('<div></div>') .hide() .appendTo(document.body) ; if ($msg.is(:hidden)) {
Imagine I have this code: var myFunc1 = function(event) { alert(1); } var myFunc2
this code var tip = <p class='adobe-reader-download'>Most computers will open PDF documents automatically, but
I have this code: var originalBorder = container.css("border"); container.hover(function(event) { event.stopPropagation(); $(this).css("border", "1px solid
Examine this code var _class=function() { this.Test=100; this.Callback=function(msg) { alert(msg+\r\n+this.Test); } } function run(call)
Consider this javascript code: var bar = function () { alert(A); } var foo
Consider this code: var Someclass = new Class(); var Anotherclass = new Class(); var
Given this code: var arrayStrings = new string[1000]; Parallel.ForEach<string>(arrayStrings, someString => { DoSomething(someString); });

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.