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

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

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