Jquery 设置 id 属性并将 id 用于滚动函数的问题
我在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你应该给出属性的名称:
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");
它的 id 中的空白区域,这就是问题所在。
无论如何,感谢您尝试提供帮助。
Its the empty space in the id , that was the Problem .
Anyway thank you for try to help.