# 试图在类别顶部添加类似标题的内容

**URL:** <https://meta.discourse.org/t/trying-to-add-something-like-a-heading-on-top-of-a-category/84969>\
**Category:** Support\
**Created:** [2018年四月10日 12:04 UTC](https://meta.discourse.org/t/trying-to-add-something-like-a-heading-on-top-of-a-category/84969 "2018-04-10T12:04:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Nevoigt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniel_nevoigt/32/92920_2.png) [@Daniel\_Nevoigt](https://meta.discourse.org/u/Daniel_Nevoigt)\
**Post date:** [2018年四月10日 12:04 UTC](https://meta.discourse.org/t/trying-to-add-something-like-a-heading-on-top-of-a-category/84969/1 "2018-04-10T12:04:41Z")

</div>

Hello all,

I am trying to set a heading for different groups of forum categories I have. Perhaps someone can point me to the right direction. I was trying to use jquery method but I get stuck with only loaded the heading-element when page load is ready what results the heading only shown once on homepage, when returning the element disappeared. Second way I get stuck with elements loading multiple times 😄

Let me break it for you:

I am using that function to add the element:

`$('tr[data-category-id="9"]').before ('<tr><td class="category" style="border-color: #F37022;">My Heading</td><td class="topics"></td><td class="latest"></td></tr>');`

So, inside document ready function is the first scenario, works well, but when browsing the forum and than going back to start page, the element is gone.

When doing the following, the element loads multiple times:

```
function OnLoad (){
    $('tr[data-category-id="9"]').before ('<tr><td class="category" style="border-color: #F37022;">Eve Online</td><td class="topics"></td><td class="latest"></td></tr>');
}
$(document).ajaxComplete(function () {
    OnLoad();
});

```

Perhaps someone knows what to do, that would be great 🙂

Cheers, Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_Nevoigt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniel_nevoigt/32/92920_2.png) [@Daniel\_Nevoigt](https://meta.discourse.org/u/Daniel_Nevoigt)\
**Post date:** [2018年四月11日 11:19 UTC](https://meta.discourse.org/t/trying-to-add-something-like-a-heading-on-top-of-a-category/84969/2 "2018-04-11T11:19:46Z")

</div>

Ok, to solve that question:

> [@\[newbie\] Trouble adding script to dynamically change CSS values based on conditions](https://meta.discourse.org/t/newbie-trouble-adding-script-to-dynamically-change-css-values-based-on-conditions/51386/5):
>
> That isn’t how you’d do it there. To do it there, you’d have to do something like \<script type="text/discourse-plugin" version="0.4"\> api.onPageChange((url, title) =\> { alert('test'); }); \</script\> My original post was from a plugin perspective.

Thanks to @cpradio

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2024年六月8日 12:37 UTC](https://meta.discourse.org/t/trying-to-add-something-like-a-heading-on-top-of-a-category/84969/3 "2024-06-08T12:37:37Z")

</div>

此主题已在 2251 天后自动关闭。不再允许回复。
