用JQuery获取元素的style特性里的width属性值并复制给另外一个元素的value值,发现并没有效果,.show元素还是空,console控制台输出style特性的width属性值并不是50%,而是px指,请问这是怎么回事啊?
因为jquery获取css属性时,获取的是计算后的属性
jquery.css()
function (elem, name, extra) {
var ret, hooks;
// Make sure that we're working with the right name
name = jQuery.camelCase(name);
hooks = jQuery.cssHooks[name];
name = jQuery.cssProps[name] || name;
// cssFloat needs a special treatment
if (name === "cssFloat") {
name = "float";
}
// If a hook was provided get the computed value from there 在这里
if (hooks && "get" in hooks && (ret = hooks.get(elem, true, extra)) !== undefined) {
return ret;
// Otherwise, if a way to get the computed value exists, use that
} else if (curCSS) {
return curCSS(elem, name);
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。