JSFiddle - React, Tailwind, and code Playground

by Boba Poshtar

HTML

<h1 data-title="hey">Заголовок</h1>
<button>old img</button><br><br>
<a href="google.com">google</a><br><br>
<img src="https://media.australianmuseum.net.au/media/dd/images/Some_image.width-1200.921d770.jpg" width="32">

JavaScript

let img = document.images[0];
if (!img.hasAttribute('alt')) alert('alt not found');
img.dataset.src = img.getAttribute('src');
img.setAttribute('src', 'https://static.icdn.ru/images/reco/airguide_63889059.jpg');
let a = document.links[0];
let href = a.getAttribute('href');
if (href.substr(0, 5) === 'http:') a.style.color = 'red';
else if (href.substr(0, 6) === 'https:') a.style.color = 'green';
else a.style.color = 'silver';
delete document.querySelector('h1').dataset.title;
img.removeAttribute('width');
document.querySelector('button').onclick = function (){
	img.setAttribute('src', img.dataset.src);
};