# 函数冲突的问题——js修改

**URL:** <https://forum.freemdict.com/t/topic/23722>\
**Category:** 技术交流与词典编修\
**Created:** [2023 年9 月 30 日 03:13 UTC](https://forum.freemdict.com/t/topic/23722 "2023-09-30T03:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![Howie](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/h/9fc29f/32.png) [@Howie](https://forum.freemdict.com/u/Howie)\
发布日期： [2023 年9 月 30 日 03:13 UTC](https://forum.freemdict.com/t/topic/23722/1 "2023-09-30T03:13:16Z")

</div>

[远流字典通英汉汉英词典](https://forum.freemdict.com/t/topic/2561/1)和SIO 3.3 词典出现冲突（myFunction函数）。

 ![image](https://forumcdn.freemdict.com/uploads/default/original/3X/a/7/a721fc3eac00c80779e693070ec1910fbe8df634.png)  
[远流字典通英汉汉英词典.mdd](https://forum.freemdict.com/uploads/short-url/7Fk3cssOVphtQNOg3m8KdBZmbUw.mdd) (22.6 KB)

远流字典通英汉汉英词典没有js文件（mdd文件解压过了，没有找到），可能是mdx内部里设置的，不好修改。  
SIO词典那个js的问题，没有找到根节点，也不好修改。我不知道怎么下手

```js
function myFunction() {
  var zh = document.getElementsByName("xxx");

  if (zh[0].style.display === "inline") {
    for (var i = 0; i < zh.length; i++) {
      /* style.display 需要和css中zh_cn的display值 一致 */
      zh[i].style.display = "none";
    }
  } else {
    for (var i = 0; i < zh.length; i++) {
      zh[i].style.display = "inline";
    }
  }
}
// 剩下的代码应该没有问题吧

```

 ![19d4cceabdc5e75b5842a75fabbdceee](https://forumcdn.freemdict.com/uploads/default/original/3X/5/c/5c8747c6481f3b8d7543d7b02571f09452ba6eee.png)

我不擅长前端

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2023 年9 月 30 日 04:28 UTC](https://forum.freemdict.com/t/topic/23722/2 "2023-09-30T04:28:16Z")

</div>

可以用 `document.currentScript ` 获取脚本自身所在的节点，然后通过这个节点查找相邻的节点。

注意事项：

> **[见多识广，介绍Web开发中current开头的一些API属性 « 张鑫旭-鑫空间-鑫生活](https://www.zhangxinxu.com/wordpress/2021/11/currentscript-currenttarget-currentsrc/)**
>
> 主要介绍 currentTarget、currentScript、currentTime、currentNode 和 currentSrc 这5个属性 API，有些是 JS 对象属性，有些是 HTML 对象属性，都挺有用的。
