Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.39 KB | None | 0 0
  1. // Pour chaque boutique, on récupère le code postal complet (5 caractères).
  2. $('.shop-zipcode').each(function(){
  3.   var getShopZipcode = $(this).text();
  4.  
  5.   // On tronque chaque code postal récupéré pour ne conserver que les 2 premiers caractères
  6.   // et on l'affiche dans le DOM via un data-attribute.
  7.   $(this).closest('li').attr('data-zipcode', getShopZipcode.substring(0, 2));
  8. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement