Trim Wordpress 博客文章标题
Trim Wordpress Blogpost Title
<h2 class="entry-title" itemprop="headline">
<a href="http://alzheimerscare.in/lorem-ipsum-is-simply-dummy-text-of-the-printing-and-typesetting-industry-lorem-ipsum-has-been-the-industrys/" title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s" rel="bookmark">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s</a>
</h2>
我想 trim wordpress 博客 post 标题至少 15 个字符,页面中有很多 post,我想 trim标题使用 jquery 或 javascript 每个 post 至少 15 个字符。谢谢。
这应该可以解决问题。它找到页面上的每个标题,将其修剪为十五个字符并添加“...” - 除非您随后正在做某种 "show/hide" 效果或其他事情,否则这可能会在 [=14= 中更好地完成] ;)
$(".entry-title a").each (function () {
if ($(this).text().length > 15)
$(this).text($(this).text().substring(0,15) + '...');
});
<h2 class="entry-title" itemprop="headline">
<a href="http://alzheimerscare.in/lorem-ipsum-is-simply-dummy-text-of-the-printing-and-typesetting-industry-lorem-ipsum-has-been-the-industrys/" title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s" rel="bookmark">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s</a>
</h2>
我想 trim wordpress 博客 post 标题至少 15 个字符,页面中有很多 post,我想 trim标题使用 jquery 或 javascript 每个 post 至少 15 个字符。谢谢。
这应该可以解决问题。它找到页面上的每个标题,将其修剪为十五个字符并添加“...” - 除非您随后正在做某种 "show/hide" 效果或其他事情,否则这可能会在 [=14= 中更好地完成] ;)
$(".entry-title a").each (function () {
if ($(this).text().length > 15)
$(this).text($(this).text().substring(0,15) + '...');
});