way to print title attrib of all images on a web page
by Akram kamal
HTML
<img src="https://jquery.org/resources/home/icn-jquery-logo.png" title="jQuery Core">
<img src="https://jquery.org/resources/home/icn-ui-logo.png" title="jQuery UI">
<img src="https://jquery.org/resources/home/icn-jquerymobile-logo.png" title="jQuery Mobile">
<img src="https://jquery.org/resources/home/icn-sizzle-logo.png" title="Sizzle">
<img src="https://jquery.org/resources/home/icn-qunit-logo.png" title="jQuery Qunit">
<br>
<button>A button element</button>
<div></div>
CSS
img {
width:60px;
height:60px;
}
JavaScript
$(function(){
$( "button" ).click(function(){
$('div').html(function(){
return $('img')
.map(function() {
return $(this).attr('title');
})
.get()
.join()
});
});
});