2013-10-19 81 views
0

我正在創建一個網站的移動版本,並使其工作良好我需要從頁面上的某些標籤中刪除「樣式」屬性。如何從標籤中刪除樣式屬性?

例子:

<div class="gallery-arrows" style="top:85px;"></div><h8 style="top:85px;"><a href="https://twitter.com/TeamTHCRacing" style="color:#ffffff;">THC Racing on Twitter!</a></h8> 

,我需要爲:

<div class="gallery-arrows"></div><h8><a href="https://twitter.com/TeamTHCRacing" style="color:#ffffff;">THC Racing on Twitter!</a></h8> 

有什麼我可以添加刪除它們?像腳本或其他東西?

謝謝!

+0

參見[的removeAttribute()方法(https://developer.mozilla.org/en-US/docs/Web/API/Element.removeAttribute) – Boaz

回答

0

使用jQuery很簡單:

$('div,h8,a').removeAttr("style"); 
+1

不只是'$('[style]')。removeAttr(「style」)'? – megawac

+0

問題是「某些標籤」..所以我提到了標籤,否則你的方法非常好。 –

+1

完美地工作,謝謝 –