html - How to get all alt attributes of all img tags using jQuery -
my html code:
<img src="" alt="google.com"> <img src="" alt="gmsil.com"> <img src="" alt="gmail1.com">
how alt values of img
tag?
try : can make use of attr()
method of jquery object. iterate images , call $(this).attr('alt');
alt attribute value.
$(function(){ $('img').each(function(){ alert($(this).attr('alt')); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <img src = "" alt="google.com"> <img src = "" alt="gmsil.com"> <img src = "" alt="gmail1.com">
Comments
Post a Comment