Luk*_*nke 5 javascript css jquery
我知道样式表中的原始 css值可以使用:$('#id').css('property',''); 但是有没有办法在不改变对象属性的情况下检索值?请注意,这可能与检索当前值不同,因为它可能已从样式表值更改.
可能的"解决方案"(未经测试)
var originalTopPos = $("#testPic").css("top");
....
$("#testPic").animate({"top": originalTopPos + "px"},"slow");
Run Code Online (Sandbox Code Playgroud)
我虽然使用了很多图像......所以它比这复杂一点.
(我想将它从当前值设置为原始值,而不仅仅是从一个值跳转到另一个值)
var currentTopPos = $("#testPic").css("top");
var originalTopPos = $("#testPic").css("top", "").css("top");
$("#testPic").css("top", currentTopPos + "px")
$("#testPic").animate({"top": originalTopPos + "px"},"slow");
Run Code Online (Sandbox Code Playgroud)
我找到了答案......
$(this).attr("customAttributeName", $(this).position().top);
Run Code Online (Sandbox Code Playgroud)
然后你可以用以下命令回忆它:
$(this).attr("customAttributeName");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6806 次 |
| 最近记录: |