Monday, May 20, 2024
26
rated 0 times [  31] [ 5]  / answers: 1 / hits: 33271  / 8 Years ago, thu, july 7, 2016, 12:00:00

I have the following code to get an element by it's attribute:



document.getElementsByAttribute(xlink:href,id);


I get this error:




Uncaught TypeError: document.getElementsByAttribute is not a function




I don't understand what's going wrong, is it not a standard chrome function?


More From » google-chrome

 Answers
19

From documentation:




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




Use this:



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

[#61471] Wednesday, July 6, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
billosvaldor

Total Points: 601
Total Questions: 113
Total Answers: 113

Location: Iceland
Member since Sat, Sep 17, 2022
2 Years ago
;