Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Trying to use block of html in span to set img alt tag for multiple images on page.
- <div class="shopTextWrapper">
- <div class="shop_item">
- <a href="#dialog2" name="modal">
- <img src="objetdart/images_sm/ethanol-i.jpg" width="75" height="75"></a>
- </div>
- <br clear="all" />
- <p class="desc_text">
- Ethanol
- </p>
- </div>
- $(document).ready(function() {
- $('img').each(function(){
- var $altText = $(this).find('div p.desc_text');
- $('img').attr('alt', $altText);
- });
- });
- $('img').each(function(){
- var $altText = $(this).closest('div.shopTextWrapper').find(".desc_text").text();
- $(this).attr('alt', $altText);
- });
- var $altText = $(this).parents('.shop_item').next($('p.desc_text')).text();
Add Comment
Please, Sign In to add comment