Which is the alternative for this shorthand "{left:'+=10px'}"? Thx in advance for reply


#1


https://www.codecademy.com/courses/web-beginner-en-JwhI1/1/4?curriculum_id=50a3fad8c7a770b5fd0007a1#


{left:'+=10px'}


Question
#2

@neagumihai54321gmail

$(document).ready(function(){
  $(document).keydown(function(){
     $('div').css("left", function(){
        //$currentPos = parseInt($('div').css("left"));
        $currentPx = parseInt($('div').css("left"));
        $currentPos =  $('div').offset().left;
        alert($currentPos+" "+$currentPx);
        return (($currentPos+2));
     });
  });

== discussions / opinions ==
http://stackoverflow.com/questions/4278148/jquery-cssleft-returns-auto-instead-of-actual-value-in-chrome

http://stackoverflow.com/questions/13455931/jquery-css-firefox-dont-return-auto-values/20733569#20733569

http://stackoverflow.com/questions/6567114/adding-pixels-to-jquery-css-left-property

http://stackoverflow.com/questions/450316/html-input-element-ignores-css-leftright-properties


#3


Is it important to use "{left: "-=10px"}" instead of "{right: "+=10px"}" ... the same for top bottom right?


https://www.codecademy.com/courses/web-beginner-en-JwhI1/2/3?curriculum_id=50a3fad8c7a770b5fd0007a1#


I don't even try to pass with the alternative ... so I don't know


switch(parseInt(key.which,10)) {

So.. I know what does switch.. it's an alternative for if and implement cases..
But.. I can't figure out how this work "parseInt(key.which,10)".
If you can explain to me it will be great.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.