【发布时间】:2016-05-24 17:37:38
【问题描述】:
只是快速简单的问题。 jquery 中是否有可能在没有每个函数的情况下将元素的属性设置为它的属性?
就像这样:
$('.google-maps').attr('data-desktop-height', this.height());
【问题讨论】:
-
使用 $(this) 所以它将是 $('.google-maps').attr('data-desktop-height',$( this).height());
-
@DharaParmar 在该示例中,
$(this)将引用外部范围,而不是.google-maps元素。