我想做以下代码:-
$('.someclass').css {
width: Math.round(($(this).parent().width() / $(this).parent().height()) * $(this).parent().parent().width())
}
但我没有得到结果。
如果要根据当前元素计算赋予 CSS 属性的值,可以为该css()
方法提供一个函数,如下所示:
$('.someclass').css('width', function() {
var $parent = $(this).parent();
return Math.round(($parent.width() / $parent.height()) * $parent.parent().width())
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句