On my SharePoint site, I have multiple pages which contains Image tag.

Currently I'm working on to find those image tag which contains no alt attribute.

Is it possible using

  • C# custom code
  • Using javascript
  • PowerShell script.

Please Share some approach with useful articles. Any kind of help would be appropriated.


You can use the below jQuery snippet to find the alt tags on the page that dont have alt attribute. Optionally, you can uncomment the code and set the alt tag.

$('body img').each(function() {
    if (!$(this).attr('alt')){      
        console.log('alt text not found');  
        //set the alt text if the attribute is not found as below
        //$(this).attr('alt', "alt text");      
        var altText = $(this).attr('alt');
            console.log('alt text found no need to set value');
            //set the alt text if attribute is found but has no text as below
            //$(this).attr('alt', "alt text");      

Not the answer you're looking for? Browse other questions tagged or ask your own question.