如何“替换" jQuery的CSS属性 [英] how to "replace" css Properties with jQuery

查看:355
本文介绍了如何“替换" jQuery的CSS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JQuery如何将CSS属性更改为(在此示例中,从 left 更改为 right ) 我发现可以使用.css("left")检索值,然后可以编写一个函数来设置.css("right"),但是有一种更简单(更紧凑)的方法吗?:

with JQuery how would you change a CSS property like (in this example from left to right) I found that .css("left") could be used to retrieve the value, then I could write a function to set the .css("right"), but is there an easier (more compact) way to do it ?:

#set { left: 400px; bottom: -200px; }

#set { right: 400px; bottom: -200px; }

谢谢

推荐答案

您可以使用 .css( )

You can use .css()

var left = $('#set').css('left');
$('#set').css({
    right : left,
    left: 'auto'
});

这篇关于如何“替换" jQuery的CSS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆