Auto Add Alt Attributes To Images Using jQuery

Using jQuery to adding alt attributes to all images <img> tags.

Alt attributes of images are one of SEO Score.
alt tags screenshoot

Alt Tag SEO is technically a name.
Really, there's no such issue as AN angular position tag of a picture. it's the angular position ATTRIBUTE. however that's another discussion altogether.

The main reason for this post is to fret simply however necessary correct use of the angular position attribute is to your SEO efforts and to people who use the help of screen readers to inform them what's on a page.
In the past, marketers have just about followed 2 (2) extremes once it came to SEO-ing AN image:

1) Ignoring the angular position attribute altogether, OR
2) Stuffing the angular position attribute with a bunch of keywords.

Needless to mention, neither methodology is effective.

The angular position attribute could be a excellent spot to relinquish back to the online and an excellent place to extend the SEO-value of your content. repay by taking the time to inform the unsighted what your image represents.

And the excellent news is… you'll commonly increase guests to your web site by doing this, too.

For example: If you sell blue widgets and have a page concerning blue widgets, then possibilities are… there's a picture on the page of a blue device. Use the angular position attribute to inform the visually impaired that this what the image represents.

If it's an image of a picture on the shelf of your (say) Chicago store… then ‘tell’ your guests that within the angular position attribute. (Picture of a blue device on a shelf in our Chicago, Illinois location.) That statement clearly explains to the visually impaired (AND to go looking engines) what your image was concerning.
Now in some cases, a picture represents a decision to action — and therefore the angular position attribute ought to properly mirror that.
For instance, if you have got at the highest of a page a large, red stop sign indicating that they ought to browse some necessary content before taking action, then the angular position attribute ought to most likely say one thing like “Stop!” versus “A image of a giant, red stop sign”.

A case are often created that a picture of one thing (with a properly labelled angular position attribute) has even as a lot of or additional SEO-value than actual text (with no image).

How to add alt attributes to images dramatically ?

jquery

In this article I've made code for adding alt attributes to img tags. But iam not sure is search engine get scoped alt attributes.

Here the codes:

#Codes 1:

<script>
$(document).ready(function(){
$("img").each(function(){
    var c=$(this);
    var b=c.attr("src");
    var a=$(this).attr("alt");
        if(typeof a==typeof undefined||a==false){
c.attr("alt",b.substring(0,b.lastIndexOf(".")))}
})});
</script>

Code above using jquery and javascript functions with asking / prompted if alt attributes are found or not. If already had an ALT attributes this code will be leave it.

#Codes 2:

To set alternative text to all the images:

$('#map_canvas > img').attr('alt', 'Alternative text');

To set alternative text to images that does not have alt attribute:

$('#map_canvas > img:not([alt])').attr('alt', 'Alternative text');

Subscribe to receive free email updates:

0 Response to "Auto Add Alt Attributes To Images Using jQuery"

Post a Comment

Bila Ada posting yang kurang, atau error atau yang lainnya, silahkan tinggalkan komentar agar artikel/post di perbaiki.
Jangan Lupa Cek Box "Notify Me" agar tahu komentar kamu dibalas oleh saya.

If there are any posts that are missing, or error or anything else, please leave a comment for the article / post to be fixed.
Do not Forget Check Box "Notify Me" to know our comments replied by me.