javascript check image src

JavaScript
if (img.getAttribute('src') === 'on.png')
Source

Also in JavaScript: