<title>My Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
$( "button" ).click( function() {
$( "p" ).text( $("img").attr( "alt" ) );
<button>Get 'alt' attribute!</button>
<img src="/pix/samples/3m.jpg" alt="Photo of Rob Roy Glacier in New Zealand">