# 如何通过 jQuery 使用 plugin-api events 插入自定义 HTML

**URL:** https://meta.discourse.org/t/how-to-insert-custom-html-through-jquery-using-plugin-api-events/180330
**Category:** Development
**Tags:** plugin-api
**Created:** [2021年二月19日 11:13 UTC](https://meta.discourse.org/t/how-to-insert-custom-html-through-jquery-using-plugin-api-events/180330 "2021-02-19T11:13:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![narayanan](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@narayanan](https://meta.discourse.org/u/narayanan)
#### Post date: [2021年二月19日 11:13 UTC](https://meta.discourse.org/t/how-to-insert-custom-html-through-jquery-using-plugin-api-events/180330/1 "2021-02-19T11:13:56Z")

</div>

我尝试通过插件 API 事件（如 api.onAppEvent()、api.decorateWidget() 等）在 **编辑 CSS/HTML \> /head** 部分添加自定义 HTML。但是，我尝试的这些事件在页面加载时并未触发 jQuery。

因此，我对应该使用哪个事件感到有些困惑。因为该事件需要在页面加载时在整个站点范围内触发 jQuery，而不是阻止特定页面上的脚本。

以下是我尝试的代码：

 ![SearchButtonIssue](https://global.discourse-cdn.com/meta/original/3X/f/9/f93358e8d218522d14fbf2264868a45b1c0bf15d.png)
