Retrieving original stylesheet CSS property value in JQuery/Javascript

I know that the **original** css value from the style sheet can be assigned using: $('#id').css('property', ''); but is there a way to retrieve the value without changing the property in the object? Note that may be different from retrieving the **current** value because it may have changed from the style sheet value. -------------- Possible "solutions" (untested) var originalTopPos = $("#testPic").css("top"); .... $("#testPic").animate({"top": originalTopPos + "px"},"slow"); I'm using many images though... so it is a bit more complicated than that. -------------- (I want to animate it from the current to original value, not just jump from one value to the other) var currentTopPos = $("#testPic").css("top"); var originalTopPos = $("#testPic").css("top", "").css("top"); $("#testPic").css("top", currentTopPos + "px") $("#testPic").animate({"top": originalTopPos + "px"},"slow");
can you rephrase your question. .css('backgroundColor') will return the value of the background color of the selected element. Nothing changes.

以上就是Retrieving original stylesheet CSS property value in JQuery/Javascript的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准