我有很多<div class="productlistname"><a href="#">The Text!</a></div>
。我想要做的就是遍历所有.productlistname
并截断文本并用截断的版本替换当前文本。
这是我到目前为止所做的:
$(".productlistname a").html($(".productlistname a").html().substring(0,10));
这只是截断第一个,并用第一个截断的版本替换.productlistname的其余部分。
答案 0 :(得分:1)
$(".productlistname a").each(function() {
$(this).html($(this).html().substring(0,10));
});
答案 1 :(得分:1)
$(".productlistname a").each(function () {
$(this).html($(this).html().substring(0,10));
});
答案 2 :(得分:0)
$(".productlistname a").each(functon(){
// loopy loop
});