Jquery 设置 id 属性并将 id 用于滚动函数的问题

发布于 2025-01-17 02:36:36 字数 461 浏览 3 评论 0原文

我在 fidle 上做了一个简单的例子。 https://jsfiddle.net/johi123/0xdvq3wp/10/

来自我的项目: 总是说我没有设置 id。
url:
https://hiti-seo.com/seo-suchmaschinen-optimierung/news/seo-news.html#MUM - Eine neue ära der Suche beginnt

控制台消息:
未捕获的 TypeError: $(...).offset() 未定义

我不知道为什么它说问题在 $('')offset,问题是第二个标题 id ="#MUM - Eine neue ära der Suche beginnt”是我设定的。

I made a simmple example at fidle.
https://jsfiddle.net/johi123/0xdvq3wp/10/

from my project:
Always say me there is no id set.
url:
https://hiti-seo.com/seo-suchmaschinen-optimierung/news/seo-news.html#MUM - Eine neue Ära der Suche beginnt

console message:
Uncaught TypeError: $(...).offset() is undefined

I don't know why it"s say Problem is at $('')offset, the problem is the second headline id ="#MUM - Eine neue Ära der Suche beginnt" who i set.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

左秋 2025-01-24 02:36:36

我认为你应该给出属性的名称:

var wichid=$('li:eq(0)').attr();

=>

var wichid=$('li:eq(0)').attr("id");

I think you should give the name of the attribute:

var wichid=$('li:eq(0)').attr();

=>

var wichid=$('li:eq(0)').attr("id");

蓝梦月影 2025-01-24 02:36:36

它的 id 中的空白区域,这就是问题所在。

无论如何,感谢您尝试提供帮助。

Its the empty space in the id , that was the Problem .

Anyway thank you for try to help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文