jquery - Add to current CSS top value -


i have jquery:

$(".ta").siblings(".aname:eq(0)").css("top",+=$(".text").height()+15); 

but not working. have tried way too:

$(".ta").siblings(".aname:eq(0)").css("top",'+=$(".text").height()+15'); 

but did not work.

you have grab current top value, , add new value, , append "px" on when set value using .css()

here like:

var element = $(".ta").siblings(".aname:eq(0)"); var currtop = number(element.css("top").replace("px", "")); var amounttoadd = $(".text").height() + 15; $(element).css("top", (currtop + amounttoadd + "px")); 

and here working demo


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -