0

I have whole bunch of <div class="productlistname"><a href="#">The Text!</a></div>. What I want to do go through all .productlistname and truncate the text and replace the current text with the truncated version.

Here is what I have so far:

$(".productlistname a").html($(".productlistname a").html().substring(0,10));

This just truncate the first one and replaces the rest of .productlistname with the truncated version of the first one.

Mazzi
  • 939
  • 4
  • 12
  • 30

3 Answers3

1
$(".productlistname a").each(function() {
  $(this).html($(this).html().substring(0,10));
});
Max Shawabkeh
  • 37,799
  • 10
  • 82
  • 91
1
$(".productlistname a").each(function () {
    $(this).html($(this).html().substring(0,10));
});
Dustin Laine
  • 37,935
  • 10
  • 86
  • 125
0
$(".productlistname a").each(functon(){
  // loopy loop
});
jason
  • 1,132
  • 14
  • 32