hasAttributes fonksiyonu, elementin herhangi bir özelliğe sahip olup-olmadığını kontrol eder. Herhangi bir özelliğe sahipse true, sahip değilse false döndürür.
Not : hasAttributes ile hasAttribute farklıdır.
Sözdizimi
sonuc = element.hasAttributes()
Dönüş Değeri
sonuc | Elementin bir özelliği varsa true, diğer türlü false döner. |
Aşağıdaki örnek, sadece id özelliğine sahip bir table elementinin bu özelliği kaldırılmadan önce ve sonra hasAttributes fonksiyonunun sonuçlarını göstermektedir.
<table id="ornekTablo">
<tr>
<td>Hücre-1</td><td>Hücre-2</td>
</tr>
</table>
<script type="text/javascript">
var tablo = document.getElementById('ornekTablo');
document.write(tablo.hasAttributes() + "<br/>");
tablo.removeAttribute('id');
document.write(tablo.hasAttributes() + "<br/>");
</script>
Canlı Sonuç