I have
<img alt="text" src="source" />
I'd like to get this alt to one var in JavaScript. It'll be better if it won't be necessary to use jQuery.
Please for help :)
I have
<img alt="text" src="source" />
I'd like to get this alt to one var in JavaScript. It'll be better if it won't be necessary to use jQuery.
Please for help :)
can get any attribute by .getAttribute
i.e.
imgAlt.getAttribute("alt")
imgAlt.getAttribute("title")
const imgAlt = document.getElementById("myImg");
console.log(imgAlt.getAttribute("alt"));
<img id="myImg" alt="text" src="source" />