2016-07-07 1 views
5

ではありません。getElementsByAttributeは()私はそれの属性によって要素を取得するには、次のコードを持っている機能

document.getElementsByAttribute("xlink:href",id); 

私はエラーを取得する:

Uncaught TypeError: document.getElementsByAttribute is not a function

は私が間違って何が起こっているのか理解していませんか?クロム標準機能ではありませんか?

+0

それは 'document.getElementsByAttribute( "ID"、ID)であってはなりません;' – Rab

答えて

6

Note that this method is only available on XUL elements; it is not part of the W3C DOM.

使用この:

document.querySelectorAll("[xlink|href='"+id+"']"); 
5

Is it not a chrome standard function?

いいえ、そうではありません。 MDNから

Note that this method is only available on XUL elements; it is not part of the W3C DOM.

ではなくan attribute selectorquerySelectorAllの使用を検討してください。 documentationから

関連する問題