如何使特定类别更大胆?

时间:2013-09-13 05:06:38

标签: css categories

我正在使用the_category(', ');功能。

我想让两个特定类别以粗体显示,例如 category1 category2 ,category3,category4。 请帮助我如何实现它。

由于

1 个答案:

答案 0 :(得分:0)

(假设您在这里指的是Wordpress)

the_category()生成HTML,其中包含指向

的类别的链接
<a href=".." title=".." rel="category">Category Name</a>

这可以用于使用jQuery定位特定元素:

$('a[rel=category]').each(function(){
    if($(this).text() == 'your_category') {
        $(this).css('font-weight','bold');
    }
});

如果您想更具体一点,可以将the_category()包裹在div周围:

<div id="categories">
    <?php the_category(', '); ?>
</div>

然后使用$('#categories a[rel=category]')作为选择器。

希望这有帮助。

相关问题