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

Popular posts from this blog

c++ - list<myClass<int> * > sort -

SoapUI on windows 10 - high DPI/4K scaling issue -

java - why am i getting a "cannot resolve method" error on getApplication? -