我正在使用zepto.js爲我目前的項目,它有相同的removeAttr()
方法作爲jQuery的。removeAttr()沒有應用?
我將margin-top
應用到一堆元素 - 工作正常。
var $apply = $('aside[role="sub"], aside[role="event-info"], aside[role="attend"]');
$apply.css('margin-top', '100px'); //works fine
但是我還需要在resize-event中再次刪除它。
if ($(window).width() <= 984) {
//$apply.removeAttr('style'); //doesn't take effect
$apply.css('margin-top', '0'); //works fine
console.log('< 984');
}
,所以我能夠設置margin-top
回0
但不能完全刪除從選擇樣式屬性。
任何想法爲什麼?我沒有得到任何錯誤,只是沒有生效。
無法刪除DOM元素的 「風格」 屬性。 (這是一個屬性,而不是一個屬性。) – Pointy 2012-07-26 14:22:11