: How to retrieve img alt text with jquery or javascript? Which is the code with which we can retreive alternative text of image: It is a Cataloge with clothes. Dressers, Shirts, Skirts e.t.c.
Which is the code with which we can retreive alternative text of image:
It is a Cataloge with clothes. Dressers, Shirts, Skirts e.t.c. in front page of a site. The featured images of the categories can be changed manually from someone.
I did a check and it is asking me to give alt text. I did it to some images with alt="". But to the cataloge I cannot do it.
the code is below:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js"></script>
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{{ 'api.jquery.js' | shopify_asset_url | script_tag }}
{% if template contains 'customers' %}
{{ 'shopify_common.js' | shopify_asset_url | script_tag }}
{{ 'customer_area.js' | shopify_asset_url | script_tag }}
{% endif %}
{% if settings.display_slideshow %}{{ 'jquery.slider.js' | asset_url | script_tag }}{% endif %}
{% if settings.include_masonry %}{{ 'jquery.masonry.js' | asset_url | script_tag }}{% endif %}
{% if settings.enable_product_image_zoom %}{{ 'jquery.zoom.js' | asset_url | script_tag }}{% endif %}
{{ 'fancy.js' | asset_url | script_tag }}
{{ 'shop.js' | asset_url | script_tag }}
<script type="text/javascript">
Shopify.money_format = '{{ shop.money_format }}';
</script>
{% if template contains "product" %}
<script type="text/javascript">
jQuery(document).ready(function($){
{% if product.variants.size > 1 or product.options.size > 1 %}
new Shopify.OptionSelectors("product-select", { product: {{ product | json }}, onVariantSelected: selectCallback });
{% assign found_one_in_stock = false %}
{% for variant in product.variants %}
{% if variant.available and found_one_in_stock == false %}
{% assign found_one_in_stock = true %}
{% for option in product.options %}
$('#product-select-option-' + {{ forloop.index0 }}).val({{ variant.options[forloop.index0] | json }}).trigger('change');
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
});
</script>
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
More posts by @Phylliss660
1 Comments
Sorted by latest first Latest Oldest Best
Its difficult to understand your code,
In jQuery you can get the image alt
jQuery("#image_id").attr('alt');
if you need to set some alt tag you can use as below.
jQuery("#image_id").attr('alt','your text');
If the image have no id or class you can select with img tag too, in that case more than one img on the same page you have to loop them like below.
jQuery("img").each(function(){
var alt_var = jQuery(this).attr('alt');
});
hope its helps..
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.