There is a HTML link code with an arbitrary attribute:
<a href="#" myattribute="Test">Ссылка номер 1</a>
How to get the value of this attribute using JavaScript or jQuery?
Ссылка номе...">
There is a HTML link code with an arbitrary attribute:
<a href="#" myattribute="Test">Ссылка номер 1</a>
How to get the value of this attribute using JavaScript or jQuery?
Using jQuery
alert($('a[myattribute]').attr('myattribute'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="#" myattribute="Test">Ссылка номер 1</a>
Using javascript
var myElement = document.getElementsByTagName('A')[0]; alert(myElement.getAttribute('myattribute'));
<a href="#" myattribute="Test">Ссылка номер 1</a>
Source: https://ru.stackoverflow.com/questions/545441/
All Articles