Guest User

Untitled

a guest
Sep 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Trying to use block of html in span to set img alt tag for multiple images on page.
  2. <div class="shopTextWrapper">
  3. <div class="shop_item">
  4. <a href="#dialog2" name="modal">
  5. <img src="objetdart/images_sm/ethanol-i.jpg" width="75" height="75"></a>
  6. </div>
  7. <br clear="all" />
  8. <p class="desc_text">
  9. Ethanol
  10. </p>
  11. </div>
  12.  
  13. $(document).ready(function() {
  14. $('img').each(function(){
  15. var $altText = $(this).find('div p.desc_text');
  16. $('img').attr('alt', $altText);
  17. });
  18. });
  19.  
  20. $('img').each(function(){
  21. var $altText = $(this).closest('div.shopTextWrapper').find(".desc_text").text();
  22. $(this).attr('alt', $altText);
  23. });
  24.  
  25. var $altText = $(this).parents('.shop_item').next($('p.desc_text')).text();
Add Comment
Please, Sign In to add comment