Jquery 递归选择器
我有一大堆 。我想要做的是遍历所有
.productlistname
并截断文本并用截断的版本替换当前文本。
这是我到目前为止所得到的:
$(".productlistname a").html($(".productlistname a").html().substring(0,10));
这只是截断第一个,并将 .productlistname 的其余部分替换为第一个的截断版本。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)